Quick virtualenv fix on Mountain Lion
Overview
It appears that Apple somehow broke Python in Mountain Lion, so even with the latest Command Line Tools and Xcode 4.4 virtualenv won't properly work. During virtual environment creation it will try to install easy_install inside /Library hierarchy. So let's give it a quick workaround. Let's install custom python into your $HOME-directory using pythonbrew!
Installing proper Command Line Tools
Without the Apple Mac Developer account you won't even see the proper download link for the latest CL Tools and the old one won't work on ML. So here's the link: http://goo.gl/iBTXh. It points towards the Apple website so don't worry.
Let's try pythonbrew
Next we will install pythonbrew: curl -kL http://xrl.us/pythonbrewinstall | bash
After that we need to put pythonbrew's bin/ directory before anything else in your $PATH. Add this line to the end of your .bashrc file: [[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc
Source your new .bashrc: source ~/.bashrc
(or reopen your terminal) and we are ready to install our custom python.
Install desired python
With pythonbrew we can have multiple versions of python interpreters installed at the same time and conveniently switch between them. Let's install 2.7.2: pythonbrew install 2.7.2
The compilation is done in the background and can take a while. You can view the build log using tail -f $HOME/.pythonbrew/log/build.log
After successful installation you need to switch your pythonbrew's python version to 2.7.2: pythonbrew switch 2.7.2
Finally, working virtualenv
pip is already installed here, so all you need is to fire pip install virtualenv
and you are good to go.
This comment has been minimized.
brainsik commentedJul 25, 2012
This tool will install virtualenv & virtualenvwrapper with one command:
https://github.com/brainsik/virtualenv-burrito#readme