Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python+pip install bson error

Tags:

python

pip

bson

i want install 3rd library -> bson. but error with next, who knows why?

# 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/

system info:

# 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 and pip version info:

# python -V
Python 2.7.13
# pip --version
pip 10.0.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
like image 265
lotus echo Avatar asked Mar 29 '26 17:03

lotus echo


2 Answers

pip authors were warning for many years to not import pip. Finally at version 10 they restructured their code.

To continue using pip with packages that import pip you need pip version 9:

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

PS. There is already a bug report.

like image 54
phd Avatar answered Mar 31 '26 06:03

phd


easy fix:

pip uninstall bson
pip uninstall pymongo
pip install pymongo
like image 40
Adam Liu Avatar answered Mar 31 '26 07:03

Adam Liu