Learning how to install python packages

In an earlier post I described my python setup for Debian, this time I’ve kept notes while working yesterday to get a stable python environment on Mac OS X Mountain Lion (10.8.1). I’ve used the notes to write up the steps that worked, there were a lot of dead ends along the way that I haven’t included.

Since the upgrade to Mountain Lion, I’ve had a lot of problems with my python environment not working, and in trying to sort it out I’d somehow managed to end up with a broken easy_install. I think I achieved that by downloading and installing the latest command line tools from the Apple Developer website instead of through XCode. So I’d recommend sticking with the one installed through XCode. But at that stage I wasn’t taking notes about what I was trying, so I’m not sure.

I fixed easy_install by installing distribute:

I noticed that my path had /usr/bin ahead of /usr/local/bin, but this should probably be the other way around.

This is being set by /etc/paths  and the ~/.bashrc

Changed /etc/paths to have:

Then started setting up my ipython, scipy and pandas environment. Using “distribute” in the virtual environment seems to work better at building some packages.

The scipy install failed, and I fixed it by installing the dev version as suggested here – http://www.thisisthegreenroom.com/2012/compiling-scipy-on-mountain-lion/

The matplotlib install failed, so I then followed these instructions –
https://gist.github.com/1860902 (but not step 5) to install X11 and pkg-config as follows:

download and install X11 from

logged out and in to activate X11.

(not sure this actually helped)

The x11 libraries are not on the path (which I thought was what pkg-config was meant to fix?) Fixed by using:


So I now have a virtual environment with the right Python packages installed, and I understand a bit more about working out how to install packages when they fail. I still need to work out what the difference is between pip, distribute and easy_install.

  1. Hi Brenda,
    Just wondering why you didn’t use ScipySuperpack? Is it missing something important?

  2. Hello Chris,

    I think SciPySuperpack is great, and it is what I used to get started on using python on OS X in January 2012. Around September (the time of the post we are commenting on) I was trying out some other packages and dev versions of the packages included in SciPySuperpack. So I had to learn more about solving install conflicts anyway. I also had some problems with SciPySuperpack not working (which I raised issues for). Chris Fonnesbeck keeps it up to date with stable releases of the included packages and is very helpful and quick to fix problems.

Leave a Reply

Your email address will not be published.