Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Quick virtualenv fix on Mountain Lion

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.

@brainsik

This tool will install virtualenv & virtualenvwrapper with one command:

https://github.com/brainsik/virtualenv-burrito#readme

@Buzzingrobot

I'm on 10.8 and the command line package is telling me it's only for 10.7.

@thesharp
Owner

I'm on 10.8 and the command line package is telling me it's only for 10.7.

What is your CL package filename?

@thomaspurchas

Have you tried the developer preview CL tools (Preview 3). They have worked for me and you don't need a Mac OS developer subscription, but you may need a free developer account . Get them here: https://developer.apple.com/downloads/

@thesharp
Owner

There are new (Late July) CL tools released today, they will do too.

@thomaspurchas

Ahh, I haven't seen those yet. Thanks

@jiaaro

Finally got this working by installing the Command line tools via xcode:

You need to install Xcode 4.4 (from the app store) and then, within xcode open Xcode > Preferences (or press Cmd + ,) then open the downloads tab and install the Command Line Tools.

@thesharp
Owner
@adamgotterer

@thesharp I had the same issue with it saying it was only for 10.7. If you upgrade to xcode 4.4 and download from the download preference pane, it downloads successfully. Unfortunately, my python environment is still pretty messed up.

@thesharp
Owner
@adamgotterer

I actually just got everything working. I've seen lots of people complaining about different issues. For me I was having trouble running python specific packages. It seems that mountain lion did something to pip and it's packages. Thankfully I don't have too many of them. I had to sudo easy_install pip (not sure why I needed sudo). Then I used pip to re-install broken packages. Things appear to be working right now.

@thomaspurchas

I should point out that installing Mountain Lion wipes your site-packages folder completly so you need to reinstall all of your packages using Pip. Also I found it much easier to destroy all of my virtualenv environments and rebuild them from requirements files.

@thesharp
Owner
@zvikico

For those looking for a quick solution - downloading and installing the latest 2.7.x python from python.org solved the problem. Make sure you reboot your machine after the installation is complete, otherwise nothing will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.