Python – Install “scientific python” environment: OS X 10.7 + Numpy + Scipy + Matplotlib

matplotlibnumpypythonscipy

What could I have done instead in order to get these items working together? Should I just move everything to windows 7 (I'd prefer not, but if it's the only reliable way.)

Okay, so here's what's happened: I wanted to install numpy/scipy onto my mac, which runs 10.7. Unfortunately numpy ver1.6 only supports up python 2.6. I go and install python 2.6, But python 2.6 doesn't work; app-icon bounces and automatically quits. (This strange in retrospect, because I heard python 2.7 and numpy ships with mac; but when I tried using sample code from the numpy website it failed.)

Now in a real bind, so I eventually found this: http://stronginference.com/scipy-superpack/
Which somehow installs numpy 2.0, Scipy (0.11), Matplotlib (1.2), iPython (0.12), Pandas (0.5.1) as well as PyMC (2.2 alpha).

It seemed like it worked, Numpy did work with some example code they provided on python 2.7. But as I was working on practice problems, I found that matplotlib is not working at all anymore. The python launcher (I think…. it's python launcher app-icon, but just says "python" for the name) bounces in the app tray and eventually freezes. I was worried it could be because I had matplotlib 1.1 installed before, so I followed instructions to clean uninstall matplotlib followed by installation with scipy-superpack.

Still fails the same way as before. Now I've done a clean install of matplotlib 1.1 in hopes that it works. And when I "import pylab" it throws up a ton of error messages.

Any advice would be greatly appreciated.

Best Answer

If you are ready to follow a longer term approach, I would advise that you go through the MacPorts package manager: they have all this software packaged, and it just works. I followed this approach successfully with Mac OS X Lion.

You basically first install the MacPorts package manager, and then install programs like explained on their site: sudo port install python27 py27-numpy py27-scipy py27-matplotlib py27-ipython.

One advantage of the MacPorts approach is that you do not touch Mac OS X's original software: their programs are stored in /opt/local/ (along with some programs in /Applications/MacPorts/, like Gimp or Python's Idle). The install procedure should put /opt/local/ in front of your path, so that you automatically use MacPort's programs instead of those installed by default on the Mac.

Another advantage is that MacPorts automatically downloads any additional necessary programs (dependencies) for you.

Their packages are quite up-to-date, and there are many of them (12k+, at the time of this writing). So, with the MacPorts route, you'll have access to many additional programs.

Side note: I have a long experience with the another package manager for Mac OS X: Fink. I find MacPorts simpler, more robust, and more up-to-date. So, I heartily recommended it.

PS: I believe that you also have to create a new python MacPorts command with sudo port select python python27, and do the same for IPython: sudo port select ipython ipython27. These commands in effect define which version of Python and IPython will be called when you use the python and ipython commands in a shell.

PPS by JD Long: I tried following these instructions on May 16, 2012 and, possibly because of versions, or possibly because of idiosyncrasies on my Mac, I had to also run sudo port install py27-tornado py27-zmq in order to get a fully functioning ipython/notebook stack working.