pkg_resources.DistributionNotFound: The 'pip==

2019-02-20 03:42发布

问题:

Working on Ubuntu and python 2.7.6. when I try to use pip, Just pip followed by enter,

File "/usr/local/bin/pip", line 5, in <module>
  from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3095, in  <module>
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3081, in _call_aside
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3108, in _initialize_master_working_set
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 660, in _build_master
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 673, in _build_from_requirements
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 846, in resolve
pkg_resources.DistributionNotFound: The 'pip==1.5.4' distribution was not found and is required by the application

回答1:

Updated for 2017 (Ubuntu 17)

sudo apt-get purge python-pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
pip --version
rm get-pip.py


回答2:

Faced the same problem with ubuntu 14.04 ,python2.7.6 and pip 1.5.4. I did this,

 sudo apt-get install --reinstall python2.7

To reinstall python (not necessary though)

 sudo apt-get purge python-pip

(removing python pip)

 wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py

(download from this,this is upgraded version (9))

 sudo python get-pip.py
 sudo pip install package-name

This worked!