python + pip安装bson错误

时间:2018-04-16 09:57:02

标签: python pip bson

我想安装第3个库 - > 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)

3 个答案:

答案 0 :(得分:4)

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

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

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

PS。已有bug report

答案 1 :(得分:2)

简单修复:

pip uninstall bson
pip uninstall pymongo
pip install pymongo

答案 2 :(得分:0)

尝试pip install --upgrade setuptools然后重新开始。