For posterity, and to save some people some trouble with their install, here is what I have done to get up to a working matplotlib on my Mac running Mac OS X Snow Leopard 10.6.8:
- Download and install the python.org python 2.7 from the .dmg installer
- Download this egg. To run it, you may have to rename it to have a .egg extention rather than a .egg.sh one.
- Open a terminal
- Execute the file you renamed before by typing “sudo bash path/to/filename” – to get the path to filename, you can open a Finder window showing the file, then drag the icon onto the terminal – that will insert the full path.
- Install pip by typing “sudo easy_install pip”
- Install GNU readline by typing “sudo pip install readline”
- Install nose (used for testing) by typing “sudo pip install nose”
- Install iPython by typing “sudo pip install ipython”
- Download and install the NumPy binary distribution
- Download and install the SciPy binary distribution
- Download and install the Activestate tcl/tk – this is the one recommended on python.org. If you click through the python website to the Activestate one note that you don’t have to fill in your info to download the files.
You should now have a working scientific environment that allows you to do most of the things you would be able to in a stock install of Matlab with a couple of packages thrown in, except for plotting. The next step is a bit more arduous, because the default binary install of Matplotlib does not work (at least not for me). This is what I had to do to get it working:
- Download and install XCode
- Install git
- Open up a terminal
- Type “git clone git://github.com/matplotlib/matplotlib.git”
- Type “cd matplotlib”
- Type “sudo su” and provide your password when prompted
- Create a temporary directory (XXX in the following command) then do ‘ARCHFLAGS=”-arch x86_64″ LDFLAGS=”-arch x86_64″ CFLAGS=”-arch x86_64″ FFLAGS=”-m64″ PREFIX=XXX make -f make.osx fetch deps mpl_build mpl_install’
- Type “cp -r XXX/lib/site-packages/* /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/”
To test if all this worked, do the following:
- Test ipython: “iptest’
- Start ipython and do
- Test numpy: “import numpy; numpy.test()”
- Test scipy: “import scipy; scipy.test()”
- Test matplotlib: “import matplotlib; matplotlib.test()”
Don’t be too upset if some errors occur: it seems the test suites aren’t entirely up to date. As long as you don’t see a segfault or ipython crash, it should be ok.
Leave a Reply