python+pip安装bson报错

python+pip install bson error

我想安装第三个库 -> bson。 但是下一个错误,谁知道为什么?

# pip install bson
Collecting bson
  Using cached bson-0.5.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-cP7YdW/bson/setup.py", line 8, in <module>
        from pip import get_installed_distributions
    ImportError: cannot import name get_installed_distributions

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-cP7YdW/bson/

系统信息:

# uname -a
Linux instance-says 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux

python 和 pip 版本信息:

# python -V
Python 2.7.13
# pip --version
pip 10.0.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

再试一次 pip install --upgrade setuptools 和 运行。

pip 作者多年来一直警告不要 import pip。最后,在版本 10 中,他们重组了代码。

要继续将 pip 与导入 pip 的软件包一起使用,您需要 pip 版本 9:

python -m pip install -U 'pip>=9,<10'

PS。已经有 bug report.

轻松修复:

pip uninstall bson
pip uninstall pymongo
pip install pymongo