DistributionNotFound error after upgrading pip

2019-02-06 23:10发布

In reading about virtualenv here I realized I didn't have pip 1.3+, so I ran pip install --upgrade pip and now when I run pip --version i get the following:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg/pkg_resources.py", line 2807, in <module>
    parse_requirements(__requires__), Environment()
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg/pkg_resources.py", line 594, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==1.2.1

If it helps, or is at all relevant, my $PATH looks like this:

/usr/local/bin:/usr/local/share/python:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

Also, which pip gives me /usr/local/bin/pip.

Not sure what to do about the error. Thanks.

8条回答
家丑人穷心不美
2楼-- · 2019-02-06 23:50

There is no need to uninstall python and install it back. Get the latest distribute package installed and then update pip with it should do the trick.

wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo python ez_setup.py
sudo easy_install -U pip
查看更多
够拽才男人
3楼-- · 2019-02-06 23:53

The brutal way:

Assuming you are using homebrew for Mac (because I see /usr/local/Cellar), I suggest to

  • remove (or backup) /usr/local/lib/python2.7, and
  • brew rm python && brew install python.

This will definitely install pip 1.3.3 alongside of python. Your distribute will also be 0.6.35.

The soft way:

From /usr/local/lib/python2.7/site-packages just remove:

  • easy-install.pth
  • pip-1.2.1-py2.7.egg or other versions of pip you have.
  • distribute-0.6.34-py2.7.egg or other versions

Then, brew rm python && brew install python. This will leave all your other bindings from brew and installed stuff intact. Python, pip and distribute will be replaced with up-to-date versions.

additionally:

Please check that you don't have a distribute or setuptools or pip located in /Library/Python/2.7/site-packages. That dir is re-used by all python 2.7 versions (brewed or from OS X) and will interferre with the pip/distribute already installed by Homebrew.

查看更多
登录 后发表回答