解决caffe中的python环境安装的问题(补充)

上一篇(解决caffe中的python环境安装的问题_qiuchangyong的博客-CSDN博客)说到了安装过程中遇到的常见问题,其实还有一个忘了补充,就是在执行命令"sudo python -m pip install -r requirements.txt"后,出现protobuf安装失败的情况:

$ sudo python -m pip install -r requirements.txt 
Requirement already satisfied: Cython>=0.19.2 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 1))
Requirement already satisfied: numpy>=1.7.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 2))
Requirement already satisfied: scipy>=0.13.2 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 3))
Requirement already satisfied: scikit-image>=0.9.3 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 4))
Requirement already satisfied: matplotlib>=1.3.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 5))
Requirement already satisfied: ipython>=3.0.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 6))
Requirement already satisfied: h5py>=2.2.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 7))
Requirement already satisfied: leveldb>=0.191 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 8))
Requirement already satisfied: networkx>=1.8.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 9))
Requirement already satisfied: nose>=1.3.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 10))
Requirement already satisfied: pandas>=0.12.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 11))
Requirement already satisfied: python-dateutil<2,>=1.4 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 12))
Collecting protobuf>=2.5.0 (from -r requirements.txt (line 13))
  Using cached https://files.pythonhosted.org/packages/6c/be/4e32d02bf08b8f76bf6e59f2a531690c1e4264530404501f3489ca975d9a/protobuf-4.21.0-py2.py3-none-any.whl
protobuf requires Python '>=3.7' but the running Python is 2.7.18
You are using pip version 9.0.1, however version 23.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

这是由于下载的protobuf版本过高而不能适配Python2.7导致的,解决方法就是限制protobuf版本,可以将requirements.txt中的"protobuf>=2.5.0"一行改为"protobuf>=2.5.0,<3",再安装。

结果又遇到一个错误:

$ sudo python -m pip install -r requirements.txt 
Requirement already satisfied: Cython>=0.19.2 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 1))
Requirement already satisfied: numpy>=1.7.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 2))
Requirement already satisfied: scipy>=0.13.2 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 3))
Requirement already satisfied: scikit-image>=0.9.3 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 4))
Requirement already satisfied: matplotlib>=1.3.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 5))
Requirement already satisfied: ipython>=3.0.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 6))
Requirement already satisfied: h5py>=2.2.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 7))
Requirement already satisfied: leveldb>=0.191 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 8))
Requirement already satisfied: networkx>=1.8.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 9))
Requirement already satisfied: nose>=1.3.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 10))
Requirement already satisfied: pandas>=0.12.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 11))
Requirement already satisfied: python-dateutil<2,>=1.4 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 12))
Collecting protobuf<3,>=2.5.0 (from -r requirements.txt (line 13))
  Downloading https://files.pythonhosted.org/packages/2c/05/10c2611da9149677abfae24e208761794561e406c37d78c36bd8dda8ea80/protobuf-2.6.1.tar.gz (188kB)
    100% |████████████████████████████████| 194kB 306kB/s 
    Complete output from command python setup.py egg_info:
    Couldn't find index page for 'google-apputils' (maybe misspelled?)
    No local packages or working download links found for google-apputils
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-vFweOs/protobuf/setup.py", line 200, in <module>
        "Protocol Buffers are Google's data interchange format.",
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 335, in __init__
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 456, in fetch_build_eggs
      File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 863, in resolve
      File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1141, in best_match
      File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1153, in obtain
      File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 522, in fetch_build_egg
      File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 666, in easy_install
    distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('google-apputils')
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-vFweOs/protobuf/
You are using pip version 9.0.1, however version 23.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

根据提示,知道是google-apputils没有安装,于是安装"sudo python -m pip install google-apputils",安装完之后,再执行命令"sudo python -m pip install -r requirements.txt"

$ sudo python -m pip install -r requirements.txt
[sudo] lixiang 的密码: 
Requirement already satisfied: Cython>=0.19.2 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 1))
Requirement already satisfied: numpy>=1.7.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 2))
Requirement already satisfied: scipy>=0.13.2 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 3))
Requirement already satisfied: scikit-image>=0.9.3 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 4))
Requirement already satisfied: matplotlib>=1.3.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 5))
Requirement already satisfied: ipython>=3.0.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 6))
Requirement already satisfied: h5py>=2.2.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 7))
Requirement already satisfied: leveldb>=0.191 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 8))
Requirement already satisfied: networkx>=1.8.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 9))
Requirement already satisfied: nose>=1.3.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 10))
Requirement already satisfied: pandas>=0.12.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 11))
Requirement already satisfied: python-dateutil<2,>=1.4 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 12))
Collecting protobuf<3,>=2.5.0 (from -r requirements.txt (line 13))
  Downloading https://files.pythonhosted.org/packages/2c/05/10c2611da9149677abfae24e208761794561e406c37d78c36bd8dda8ea80/protobuf-2.6.1.tar.gz (188kB)
    100% |████████████████████████████████| 194kB 305kB/s 
Requirement already satisfied: python-gflags>=2.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 14))
Requirement already satisfied: pyyaml>=3.10 in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 15))
Requirement already satisfied: Pillow>=2.3.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 16))
Requirement already satisfied: six>=1.1.0 in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 17))
Requirement already satisfied: cloudpickle>=0.2.1 in /usr/local/lib/python2.7/dist-packages (from scikit-image>=0.9.3->-r requirements.txt (line 4))
Requirement already satisfied: PyWavelets>=0.4.0 in /usr/local/lib/python2.7/dist-packages (from scikit-image>=0.9.3->-r requirements.txt (line 4))
Requirement already satisfied: pytz in /usr/local/lib/python2.7/dist-packages (from matplotlib>=1.3.1->-r requirements.txt (line 5))
Requirement already satisfied: backports.functools-lru-cache in /usr/local/lib/python2.7/dist-packages (from matplotlib>=1.3.1->-r requirements.txt (line 5))
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python2.7/dist-packages (from matplotlib>=1.3.1->-r requirements.txt (line 5))
Requirement already satisfied: subprocess32 in /usr/local/lib/python2.7/dist-packages (from matplotlib>=1.3.1->-r requirements.txt (line 5))
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python2.7/dist-packages (from matplotlib>=1.3.1->-r requirements.txt (line 5))
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python2.7/dist-packages (from matplotlib>=1.3.1->-r requirements.txt (line 5))
Requirement already satisfied: setuptools>=18.5 in /usr/local/lib/python2.7/dist-packages/setuptools-36.6.0-py2.7.egg (from ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: backports.shutil-get-terminal-size; python_version == "2.7" in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: simplegeneric>0.8 in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: traitlets>=4.2 in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: pygments<2.6 in /usr/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.4 in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: pathlib2; python_version == "2.7" or python_version == "3.3" in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: decorator in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: pickleshare in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: pexpect; sys_platform != "win32" in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: enum34; python_version == "2.7" in /usr/local/lib/python2.7/dist-packages (from traitlets>=4.2->ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: ipython-genutils in /usr/local/lib/python2.7/dist-packages (from traitlets>=4.2->ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: wcwidth in /usr/local/lib/python2.7/dist-packages (from prompt-toolkit<2.0.0,>=1.0.4->ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: typing; python_version < "3.5" in /usr/local/lib/python2.7/dist-packages (from pathlib2; python_version == "2.7" or python_version == "3.3"->ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: scandir; python_version < "3.5" in /usr/local/lib/python2.7/dist-packages (from pathlib2; python_version == "2.7" or python_version == "3.3"->ipython>=3.0.0->-r requirements.txt (line 6))
Requirement already satisfied: ptyprocess>=0.5 in /usr/local/lib/python2.7/dist-packages (from pexpect; sys_platform != "win32"->ipython>=3.0.0->-r requirements.txt (line 6))
Building wheels for collected packages: protobuf
  Running setup.py bdist_wheel for protobuf ... done
  Stored in directory: /root/.cache/pip/wheels/b6/ed/a8/e3c2135065922705a433364cfba163707da6d8f8d38e2cc972
Successfully built protobuf
Installing collected packages: protobuf
Successfully installed protobuf-2.6.1
You are using pip version 9.0.1, however version 23.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

没有出现错误,大功告成!

相关推荐
nuclear20111 小时前
使用Python 在Excel中创建和取消数据分组 - 详解
python·excel数据分组·创建excel分组·excel分类汇总·excel嵌套分组·excel大纲级别·取消excel分组
Lucky小小吴1 小时前
有关django、python版本、sqlite3版本冲突问题
python·django·sqlite
GIS 数据栈1 小时前
每日一书 《基于ArcGIS的Python编程秘笈》
开发语言·python·arcgis
爱分享的码瑞哥2 小时前
Python爬虫中的IP封禁问题及其解决方案
爬虫·python·tcp/ip
傻啦嘿哟3 小时前
如何使用 Python 开发一个简单的文本数据转换为 Excel 工具
开发语言·python·excel
B站计算机毕业设计超人3 小时前
计算机毕业设计SparkStreaming+Kafka旅游推荐系统 旅游景点客流量预测 旅游可视化 旅游大数据 Hive数据仓库 机器学习 深度学习
大数据·数据仓库·hadoop·python·kafka·课程设计·数据可视化
IT古董3 小时前
【人工智能】Python在机器学习与人工智能中的应用
开发语言·人工智能·python·机器学习
湫ccc4 小时前
《Python基础》之pip换国内镜像源
开发语言·python·pip
hakesashou4 小时前
Python中常用的函数介绍
java·网络·python
菜鸟的人工智能之路4 小时前
极坐标气泡图:医学数据分析的可视化新视角
python·数据分析·健康医疗