Adventures with Mountain Lion – Restoring Virtualenvs for #Python

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.

Installing VirtualEnv is easy…

sudo easy_install virtualenv

This installed version 1.7.2 of VirtualEnv.

Next I want to re-install VirtualEnvWrapper – a set of tools to simplify working with VirtualEnv that were created by Doug Hellmann. The instructions to install VirtualEnvWrapper are straightforward.

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
pkg_resources.DistributionNotFound: pip==1.0.2

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 again…

sudo pip install virtualenvwrapper

This installed version 3.5 of VirtualEnvWrapper

I then loaded a new Terminal window and the earlier VirtualEnvWrapper error message had disappeared. We are back in business!
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s