After a fresh upgrade of my Macbook Air with OS X Lion, I’m left with the default system Python, and nothing of my old stuff in the System Library path.
I first tried to install numpy. The default installed version is 1.5.0, I want the latest version. This was quite simple
$ sudo easy_install numpy
$ python
>>> import numpy
>>> print numpy.__version__
1.6.1
Other easy install steps: scikit-learn (no dependency, except the above), nose, dexy, ipython.
Actually, I wasn’t able to install scipy, neither with setuptools
, nor with a fresh tar.gz
archive. To my surprise, however, the installation of Matplotlib went fine! (I remember having to clean a lot of post-install stuff during my previous install on OS X SL.)
About scipy, a little googling suggests that the problem may be related to a broken numpy install (through either pip
or easy_install
), where some files are simply missing (e.g., npymath.ini
that scipy complains not to found). So, I tried to compile everything the usual way. First, I cleaned up my fresh numpy install:
$ cd /Library/Python/2.7/site-packages
$ sudo easy_install -m numpy
$ sudo rm -rf numpy-1.6.1-py2.7-macosx-10.7-intel.egg/
(Likewise, I had to remove matplotlib
and scikit-learn
.)
Then,
Download the latest numpy 1.6.1
from SourceForge.net
Build it,
```
$ python setup.py build --fcompiler=gfortran
$ sudo python setup.py install
```
Check that we now have npymath.ini
Now, let’s try installing scipy
again. Using pip
, I still get an error (about some C code). So, I used the tar.gz
source files directly, and:
$ sudo python setup.py install
and everything seems to go fine up to the sparse/*
stuff where I got error with compilation of veclib_cabi_c.c
. This strongly resembles what was described in one of the scipy tickets. It is suggested to just add at the top of scipy/sparse/linalg/eigen/arpack/ARPACK/FWRAPPERS/veclib_cabi_c.c
:
#include <complex.h>
Now, there is a new error with scipy/linalg/src/fblaswrap_veclib_c.c
that I fixed in the same way. And, ô miracle, everything compiled fine till this end where I could read:
Writing /Library/Python/2.7/site-packages/scipy-0.9.0-py2.7.egg-info
running install_clib
I didn’t run the test suite, though.
To sum up, to get a working installation of numpy, scipy, matplotlib, and all scientific libraries you want,
nose
via easy_install
numpy
from sourcescipy
from source (you’ll need to patch veclib_cabi_c.c
and fblaswrap_veclib_c.c
)matplotlib
via easy_install
While we are in, let’s install cython: it went smoothly with easy_install
. Finally, I was able to install the scikit-statsmodels which depends on numpy and scipy, but from the pypi tarball only (the automated install via easy_install
seems to hang on a broken git
revision). I used:
$ python setup.py install --with-cython
Below is a little check, using %run example_predict.py
in IPython 0.10.2:
and an illustration with the mean shift algorithm, from the scikit.learn
:
Welcome OS X Lion again: How fortunate!