解决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.

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

相关推荐
小馒头学python1 分钟前
机器学习是什么?AIGC又是什么?机器学习与AIGC未来科技的双引擎
人工智能·python·机器学习
神奇夜光杯11 分钟前
Python酷库之旅-第三方库Pandas(202)
开发语言·人工智能·python·excel·pandas·标准库及第三方库·学习与成长
千天夜22 分钟前
使用UDP协议传输视频流!(分片、缓存)
python·网络协议·udp·视频流
测试界的酸菜鱼26 分钟前
Python 大数据展示屏实例
大数据·开发语言·python
羊小猪~~30 分钟前
神经网络基础--什么是正向传播??什么是方向传播??
人工智能·pytorch·python·深度学习·神经网络·算法·机器学习
放飞自我的Coder1 小时前
【python ROUGE BLEU jiaba.cut NLP常用的指标计算】
python·自然语言处理·bleu·rouge·jieba分词
正义的彬彬侠1 小时前
【scikit-learn 1.2版本后】sklearn.datasets中load_boston报错 使用 fetch_openml 函数来加载波士顿房价
python·机器学习·sklearn
张小生1802 小时前
PyCharm中 argparse 库 的使用方法
python·pycharm
秃头佛爷2 小时前
Python使用PDF相关组件案例详解
python
Dxy12393102162 小时前
python下载pdf
数据库·python·pdf