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


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

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

    结果又遇到一个错误:

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

    1. $ sudo python -m pip install -r requirements.txt
    2. [sudo] lixiang 的密码:
    3. Requirement already satisfied: Cython>=0.19.2 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 1))
    4. Requirement already satisfied: numpy>=1.7.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 2))
    5. Requirement already satisfied: scipy>=0.13.2 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 3))
    6. Requirement already satisfied: scikit-image>=0.9.3 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 4))
    7. Requirement already satisfied: matplotlib>=1.3.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 5))
    8. Requirement already satisfied: ipython>=3.0.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 6))
    9. Requirement already satisfied: h5py>=2.2.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 7))
    10. Requirement already satisfied: leveldb>=0.191 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 8))
    11. Requirement already satisfied: networkx>=1.8.1 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 9))
    12. Requirement already satisfied: nose>=1.3.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 10))
    13. Requirement already satisfied: pandas>=0.12.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 11))
    14. Requirement already satisfied: python-dateutil<2,>=1.4 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 12))
    15. Collecting protobuf<3,>=2.5.0 (from -r requirements.txt (line 13))
    16. Downloading https://files.pythonhosted.org/packages/2c/05/10c2611da9149677abfae24e208761794561e406c37d78c36bd8dda8ea80/protobuf-2.6.1.tar.gz (188kB)
    17. 100% |████████████████████████████████| 194kB 305kB/s
    18. Requirement already satisfied: python-gflags>=2.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 14))
    19. Requirement already satisfied: pyyaml>=3.10 in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 15))
    20. Requirement already satisfied: Pillow>=2.3.0 in /usr/local/lib/python2.7/dist-packages (from -r requirements.txt (line 16))
    21. Requirement already satisfied: six>=1.1.0 in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 17))
    22. 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))
    23. 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))
    24. Requirement already satisfied: pytz in /usr/local/lib/python2.7/dist-packages (from matplotlib>=1.3.1->-r requirements.txt (line 5))
    25. 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))
    26. Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python2.7/dist-packages (from matplotlib>=1.3.1->-r requirements.txt (line 5))
    27. Requirement already satisfied: subprocess32 in /usr/local/lib/python2.7/dist-packages (from matplotlib>=1.3.1->-r requirements.txt (line 5))
    28. 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))
    29. 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))
    30. 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))
    31. 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))
    32. Requirement already satisfied: simplegeneric>0.8 in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
    33. Requirement already satisfied: traitlets>=4.2 in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
    34. Requirement already satisfied: pygments<2.6 in /usr/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
    35. 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))
    36. 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))
    37. Requirement already satisfied: decorator in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
    38. Requirement already satisfied: pickleshare in /usr/local/lib/python2.7/dist-packages (from ipython>=3.0.0->-r requirements.txt (line 6))
    39. 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))
    40. 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))
    41. 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))
    42. 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))
    43. 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))
    44. 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))
    45. 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))
    46. Building wheels for collected packages: protobuf
    47. Running setup.py bdist_wheel for protobuf ... done
    48. Stored in directory: /root/.cache/pip/wheels/b6/ed/a8/e3c2135065922705a433364cfba163707da6d8f8d38e2cc972
    49. Successfully built protobuf
    50. Installing collected packages: protobuf
    51. Successfully installed protobuf-2.6.1
    52. You are using pip version 9.0.1, however version 23.2.1 is available.
    53. You should consider upgrading via the 'pip install --upgrade pip' command.

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

  • 相关阅读:
    一文搞懂如何自己写一个Python库
    低代码:让软件开发不再遥不可及
    【二叉树】从二叉树一个节点到另一个节点每一步的方向
    基于量子随机游走的图像加密算法
    40 个机器学习面试问题(文末福利送书)
    Android学习笔记 1.1 Android的发展和历史
    前端入门到入土?
    UE5 虚幻引擎,打开空间蓝图,出现未识别的选项卡
    MySQL索引优化
    软件测试周刊(第87期):天下就没有偶然,那不过是化了妆的、戴了面具的必然。
  • 原文地址:https://blog.csdn.net/qiuchangyong/article/details/133564879