public
Last active

Quick virtualenv fix on Mountain Lion

  • Download Gist
ML, Python and virtualenv.md
Markdown

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 tool will install virtualenv & virtualenvwrapper with one command:

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

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

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?

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/

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

Ahh, I haven't seen those yet. Thanks

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.

Do you really want Xcode on your Mac? It's huge, it's another icon in
launchpad and complete waste of space. Imho, seperate CL tools is much
better.
On Jul 26, 2012 8:07 PM, "James Robert" <
reply@reply.github.com>
wrote:

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.


Reply to this email directly or view it on GitHub:
https://gist.github.com/3179227

@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.

Yesterday I couldn't download CL tools from inside Xcode so I did as I
wrote above.

How exactly messed up by the way?
On Jul 26, 2012 8:45 PM, "Adam Gotterer" <
reply@reply.github.com>
wrote:

@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.


Reply to this email directly or view it on GitHub:
https://gist.github.com/3179227

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.

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.

Hm, it makes me curious, if I was the only one with screwed (even after
multiple reinstallations) virtualenv binary.
On Jul 26, 2012 8:53 PM, "Adam Gotterer" <
reply@reply.github.com>
wrote:

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.


Reply to this email directly or view it on GitHub:
https://gist.github.com/3179227

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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.