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:
curl -O http://python-distribute.org/distribute_setup.py sudo python distribute_setup.py
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
/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.
mkvirtualenv --distribute brmTest2 pip install tornado pip install ipython pip install numpy pip install scipy
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/
pip install -e git+https://github.com/scipy/scipy#egg=scipy-dev pip install pandas pip install matplotlib
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 http://xquartz.macosforge.org/trac/wiki
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
logged out and in to activate X11.
brew install pkg-config
(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:
export CFLAGS="-I/usr/X11/include -I/usr/X11/include/freetype2 -I/usr/X11/include/libpng12"
pip install matplotlib pip install pyzmq
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.