Installing Python, MatPlotLib & iPython on Snow Leopard
As I have detailed in a previous post the installation of MatPlotLib on Mac OS was a fairly involved process involving the using of Mac Ports to compile and build a complete Python stack. Thankfully it would seem things have become much simpler on Mac OS X 10.6.7 if you are installing Python 2.7.1, MatPlotLib 1.0.1 and iPython 0.10.1. Note: currently only the 32 bit version of Python will work consistently with MatPlotLib and iPython.
- First Python 2.7.1:
- Download the prebuilt ‘Python 2.7.1 Mac OS X 32-bit i386/PPC Installer’ DMG from python.org.
- Mount the DMG image and run the contained installer.
- Verify it worked by opening a terminal and running the command ‘python -V’ which should return ‘Python 2.7.1′.
- Next MatPlotLib 1.0.1:
- Download the prebuilt ‘matplotlib-1.0.1-python.org-32bit-py2.7-macosx10.3′ DMG from MatPlotLib’s SourceForge page.
- Mout the DMG image and run the contained installer.
- Verify this worked by opening a terminal, running python and then ‘import matplotlib’ followed by ‘print matplotlib.__version__’ which should return ’1.0.1′.
- Finally iPython 0.10.1:
- Download the iPython source ‘ipython-0.10.1.zip’ from the iPython download directory.
- Extract the zip file.
- Open a terminal window and CD into the newly extracted directory ‘ipython-0.10.1′.
- Run the command ‘sudo python setup.py install’ and enter your password when prompted.
- Verify this by running iPython with MatPlotLib via ‘ipython -pylab’ and then ‘x = randn(10000)’ followed by ‘hist(x, 100)’ and a chart window like the following image should pop up.