上一篇(解决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.
没有出现错误,大功告成!