Thursday, February 21st, 2008
Installing IPython, SciPy, and Matplotlib into Apple’s Python on upgraded Leopard
Start by reading this reference and some tips at MacResearch.
Because it obscures the nice Leopard python that includes Numpy and Dtrace, remove your old Python completely.
sudo rm -rf /Library/Frameworks/Python.framework/
Check that NumPy is already installed and working.
python
import numpy
numpy.test(1,10)
Install latest IPython, version 0.8.2. Note that I always alais untar='tar xvzf' in my bash setup.
wget http://ipython.scipy.org/dist/ipython-0.8.2.tar.gz
untar ipython-0.8.2.tar.gz
cd ipython-0.8.2
sudo python setup.py install
Install a fortran compiler binary because it is needed to compile/install Scipy. I get the PPC version of gfortran. You can also find the Intel version at HPC Mac OS X.
wget http://internap.dl.sourceforge.net/sourceforge/hpc/\
gfortran-ppc-leopard-bin.tar.gz
sudo tar -xvf gfortran-ppc-leopard-bin.tar.gz -C /
Edit a disttools file in Apple’s NumPy distribution so it is more lenient in allowing the use of the above gfortran compiler when building SciPy. Inspired by this note.
cd /System/Library/Frameworks/Python.framework/Versions/2.5/\
Extras/lib/python/numpy/distutils/fcompiler
sudo cp -p gnu.py gnu.py.bak
And edit the following lines as follows (I use mate gnu.py to edit in TextMate).
- version_match = simple_version_match(start=r'GNU Fortran (?!95)')
+ version_match = simple_version_match(start=r'GNU Fortran')
- version_match = simple_version_match(start='GNU Fortran 95')
+ version_match = simple_version_match(start='GNU Fortran')
Build and install SciPy 0.6.0. Source available here.
wget http://internap.dl.sourceforge.net/sourceforge/scipy/\
scipy-0.6.0.tar.gz
untar scipy-0.6.0.tar.gz
cd scipy-0.6.0
sudo python setup.py install
This installs SciPy here: /Library/Python/2.5/site-packages/scipy, which isn’t seen by Python at first. I added the following to my .profile.
export PYTHONPATH="/Library/Python/2.5/site-packages"
Test it after closing your terminal and re-opening. I actually have 2 failures and 3 errors, but they are things I don’t care about at the moment.
python
import scipy
scipy.test(1,10)
Install matplotlib binary.
wget http://internap.dl.sourceforge.net/sourceforge/matplotlib/\
matplotlib-0.91.2-py2.5-macosx-10.3-fat.egg
sudo easy_install -N matplotlib-0.91.2-py2.5-macosx-10.3-fat.egg
Test it out and be happy that you’re done!
ipython -pylab
plot([1,2,3])
