Installing Python for scientific computing on OSX

Python is an excellent programming language, in that it has decent structure, is quite easy to learn, and is easy to read. It’s also available as a default install on Mac OSX. Most people apparently are using Python 2.6/2.7 rather than Python 3, and this seems to be particularly true for researchers doing scientific computing. However, the basic install of Python does not contain decent libraries that allow scientific computing out-of-the-box, and a number of packages need to be installed – this is likely to be confusing for the starting user.

Whilst there are a number of packages available that are useful for scientific computing, the ones you really ought to know about above all others are NumPy, SciPy, and matplotlib. These, together with a few others, make Python more-or-less have the same capabilities as integrated language environments such as Matlab. Actually, having used both Matlab and Python, I think that both have advantages and disadvantages. They’re both quirky, and thus confusing when starting out. With Python, the question is how to get up and running conveniently for scientific computing with the least amount of effort. This post is an attempt to do a walk-through of that process. In the following guide I am using OSX 10.8 Mountain Lion, but this should work also in 10.6 and 10.7.

  1. Obtain EPDFree from Enthought, and install it. EPD – the Enthought Python Distribution – replaces your default Python install with another one, that includes all the numerical packages you might ever need. When I downloaded it I used version version py25-4.0.30002.
  2. Download Eclipse Classic. This will be the IDE (Integrated Development Environment) for your programs. I used version 4.2.1, 32 Bit.
  3. Update Eclipse by doing
    Help>Install New Software>Work with:
    Check only the PyDev box, and select ‘Next
    and install only PyDev for Eclipse
  4. Under Preferences>PyDev>Interpreter – Python>New…
    Interpreter Name: EPDPython
    Interpreter Executable: /Library/Frameworks/Python.framework/Versions/7.3/bin/python2.7
    Make sure you’ve clicked ‘Python‘ and not anything else.
    Click Ok to process a load of links….(use the default choices)

That should be it. To test the code, you can create a new project by doing:
Call it ‘HelloWorld‘ or something similar
Call it
Enter some Python code
Click the green ‘run/play’ button to run it direct from the IDE, and run as ‘Python Run

Update: you’ll also probably want to run IPython Notebooks in your browser. The standard EPDFree needs to be udpated to have the latest version of IPython. I followed the instructions here, and have copied them below:

  • sudo enpkg enstaller
  • sudo enpkg ipython
  • sudo enpkg pandas

That’s it! To run IPython in a browser notebook, just execute the following from the Terminal command line:

ipython notebook –pylab=inline


Leave a Reply