python and virtualenv problems after Mountain Lion upgrade – pebkac

python and virtualenv problems after Mountain Lion upgrade

Mountain Lion (Mac OS X 10.8) moved my cheese in the form of the following error:

Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named virtualenvwrapper.hook_loader There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python and that PATH is set properly.

Which was a bit confusing for me. Recalling that /usr/local is basically all homebrew, and that homebrew relies on system libs, I confirmed:

$ which python | xargs ls -l
lrwxr-xr-x 1 root wheel 60 Feb 6 21:44 /usr/local/bin/python -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python

So yes: system python. There was probably some combination of stuff from /usr getting removed and my PATH changes that conspired to break things. So let’s put them back, or at least get things put in place that will make everything usable again:

$ sudo /usr/local/bin/easy_install-2.7 distribute
Traceback (most recent call last):
File "/usr/local/bin/easy_install-2.7", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/", line 2603, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: distribute==0.6.24

Errr. Well perhaps we’re still getting confusion about what’s getting called from where, so let’s be very explicit:

$ sudo /usr/local/bin/python2.7 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/ distribute
Searching for distribute
Best match: distribute 0.6.28
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg
Processing dependencies for distribute
Finished processing dependencies for distribute

Cool! Progress!

$ sudo /usr/local/bin/python2.7 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/ pip
Searching for pip
Best match: pip 1.1
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip

Awesome: we can haz pip.

$ sudo /usr/local/bin/python2.7 /Library/Frameworks/Python.framework/Versions/2.7/bin/pip-2.7 install virtualenvwrapper
Downloading/unpacking virtualenvwrapper
Downloading virtualenvwrapper-3.5.tar.gz (465Kb): 465Kb downloaded
Running egg_info for package virtualenvwrapper
Successfully installed virtualenvwrapper virtualenv virtualenv-clone
Cleaning up...

So are we all set?

$ . .profile && echo "huzzah"

Looks like yes. 🙂

One response to “python and virtualenv problems after Mountain Lion upgrade”

  1. I found this really helpful. It’s also the first google search result for the error. Thx Mr. Palmer.

Leave a Reply

Your email address will not be published. Required fields are marked *

This work by tarheelcoxn is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States.