How to get scientific Python's packages working on Mac OS X Leopard

2008-07-02

I was happy to be able to run all of the greatest of Python’s package for numerical stuff before I moved on Leopard. Since I reinstalled all of my system, I didn’t try to reinstall Python’s packages with the built-in Python (2.5). While I was reading some posts on the web, I feel a little bit desperate about the installation failures that were reported for those using the 2.5 Framework.

Note that numpy is already installed with Python 2.5, which is quite good. However, I’m interested in getting scipy, matplotlib and pygame working on Leopard, as they do previously on Mac OS X 10.4. Finally, I take the shorter route and install all using source packages, and all went fine. Now, Python works out of the box.

Installing SciPy

I use the SciPy Superpack which provides the core packages: NumPy, SciPy, Matplotlib, iPython and PyMC. The installer also contains a GFortran compiler.

Note that after the installation, you have to launch a new shell session to allow for path update. Otherwise, Python won’t find the new packages. To test, just enter in the shell

>>> from scipy import *

If you don’t see any message like

from scipy import * Traceback (most recent call last):

it should be ok.

Installing Pygame

For a working pygame installation, I just follow the instructions here: MacCompile on pygame website. You have to solve several dependencies before building the pygame package, but this is just a 20 min. compilation stuff.

To test the installation, just go in the examples directory (in the downloaded archive), and test the stars.py and sound.py examples. You should get something like that

$ python stars.py
2008-07-02 09:56:19.408 Python[9025:613] Warning once: This application, 
or a library it uses, is using NSQuickDrawView, which has been deprecated.
Apps should cease use of QuickDraw and move to Quartz
$ python sound.py
Playing Sound…
  …still going…
  …still going…
  …still going…
  …still going…
…Finished

with stars.py opening a window with moving stars inside (I cannot capture them in a snapshot :-).

Now, what’s up? There are plenty of examples on how to use NumPy and SciPy, as well as Matplolib. For instance, the following Gist 549902 shows a spectrogram in an interactive graphical device (see below).

For further readings, I would recommend:

  1. Langtangen, H.P. (2008). Python Scripting for Computational Science (3rd Ed.). Springer. (See online complements)
  2. Kinser, J. (2008). Python for Bioinformatics. Jones and Bartlett.
---

Articles with the same tag(s):

El Capitan
Why I am still using Emacs
Tmux and OS X
OS X Yosemite
Some useful Mac Apps for data scientists
Collecting email usage statistics from mu
From Beamer to Deckset
Fixing some critical keyboard shortcuts in OS X terminal
A modular configuration for Emacs
Common lisp on Mavericks

---