yourfriendzak yourfriendzak - 1 year ago 102
Python Question

pip3 says "resolve pkg_resources.DistributionNotFound: pip==1.3.1"

On OSX 10.7.5, I'm trying to use the

command to install packages to python3. When I try, I get this error message:

zak$ pip3
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/", line 2793, in <module>
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/", line 673, in require
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/", line 580, in resolve
pkg_resources.VersionConflict: (pip 1.4.1 (/usr/local/lib/python3.3/site-packages), Requirement.parse('pip==1.3.1'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in <module>
from pkg_resources import load_entry_point
File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/", line 2797, in <module>
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/", line 576, in resolve
pkg_resources.DistributionNotFound: pip==1.3.1

It looks like
is demanding an old version of pip (I have 1.4.1 installed), but why? How can I fix this?

Answer Source

The problem appears to be that you have two different Python 3.3 installations, and a shared site-packages directory.* And the tool you run as pip3 is from pip 1.3.1, but the modules it uses to do its work come from pip 1.4.1.

The easiest way to solve this, unless you actually need both Python 3.3 installations, is to get rid of both of them completely, then reinstall the one you want.

The following should work (possibly with sudo for some of the commands—or using Finder and letting it tell you whether you need to authenticate).

Note that this will also partially or completely remove any other third-party Python versions (e.g., a 2.7.5), which I don't think is a problem for you, but could be for future readers.

You might want to make a list of all installed packages before uninstalling anything. (I usually do this in the hackiest way possible: fire up ipython, and let it tab-complete an import statement…)

Finally, some of these details will be different for any future readers with similar problems, but the basic ideas should be the same.

  • brew uninstall python3
  • rm -rf /Library/Frameworks/Python.framework
  • rm -rf /usr/local/lib/python*
  • rm -rf /usr/local/share/python*
  • Find where in ~/.bash_profile (or ~/.profile or elsewhere) you add the Python paths to your PATH. You may have /usr/local/share/python3 and/or something inside the Python.framework or Cellar/python3. Scrap all that you find.
  • Fire up a new shell in
  • brew doctor, and fix anything that it complains about that seems potentially relevant (the non-Homebrew MacFUSE stuff is fine as-is; the brew prune suggestion is probably worth doing, but doesn't matter here), and run it again to make sure.
  • brew install python3.
  • pip3 to reinstall any packages you deleted that you need again.

* Details:

  • Homebrew Python 3.3 is installed in /usr/local/Cellar/python3/3.3.2/, with various things symlinked into /usr/local/bin and its siblings, and possibly into /Library somewhere.
  • Another Python 3.3, possibly from the installer, is installed in /Library/Frameworks/Python.framework/Versions/3.3/, with various things possibly symlinked into /usr/local/bin or otherwise added to your PATH.
  • Both probably include /usr/local/lib/python3.3 in their site-packages search.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download