In the process of upgrading to Mac OS X Mountain Lion it appears that my Python VirtualEnv configuration broke. VirtualEnv is a must have tool for Python development, particularly if you are working across multiple projects. It allows you to create isolated Python environments. This means that you can develop in different versions of Python and with different versions of library modules without one development corrupting another.
The error I get when opening a terminal window is:
ImportError: No module named virtualenvwrapper.hook_loader
virtualenvwrapper.sh: 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/bin/python and that PATH is set properly.
Rather than spend hours digging in to what happened I figured it quicker and easier to reinstall the Virtualenv and virtualenvwrapper tools.
sudo easy_install virtualenv
This installed version 1.7.2 of VirtualEnv.
pip install virtualenvwrapper
However, I got an error. The full error script was pretty long but the important clue was at the end:
raise DistributionNotFound(req) # XXX put more info here
Pip was not installed. Okay. Let’s fix that with…
sudo easy_install pip
That worked and installed version 1.1 of pip. Now let’s try the install for VirtualEnvWrapper
sudo pip install virtualenvwrapper
I then loaded a new Terminal window and the earlier VirtualEnvWrapper error message had disappeared. We are back in business!