MacPython, SciPy and Gnuplot in MacOS X

This page describes how to get SciPy and Gnuplot working under MacOS X 10.3 (Panther). It is a small modification of instructions provided by Chris Fonnesbeck. If you have questions or comments about my attempt here please contact me.

Users of older versions of MacOS X may at least be able to get Numerical Python and Gnuplot working using these alternate instructions.

Another alternative is to use Unix versions of Python and other programs. This is easy using the Fink project. This approach requires extensive downloads. However, it makes the entire world of open-source Unix software available to you, so it may well be worth the download time. On the other other hand, MacPython is is a very elegant Mac-centric program.

The following instructions use the terminal application, which is located in /Applications/Utilities. You may also need to have enabled the root account (start /Applications/Utilities/Netinfo Manager, then select Security->Enable Root User).

MacPython Add-ons

MacPython 2.3 is included as part of MacOS 10.3 (Panther). However, the installation is missing some very useful features. They are provided by the MacPython 2.3 add-ons package, which can be obtained here. This adds PythonIDE (an excellent interactive development environment) and a Package Manager which lets you add Python extras to the MacPython installation. Once installed, try PythonIDE (in /Applications/MacPython).

Numerical Python

You may need to change some file ownerships before installing Numerical Python. In a terminal window type the command

    sudo chown USERNAME /System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3
(all one line regardless of how it appears in your browser). Here USERNAME is your user name. Alternatively you can do this in the Finder by navigating to the above (starting with your hard drive icon), control-clicking to "Get Info" and changing ownership.

Open the MacPython folder in your Applications folder and start PackageManager. Select Numeric-22.0-source, uncheck the box "For current user only," check "Install dependencies," and click Install. (Among other things this should install a directory Numeric within the directory whose ownership you changed above.) You may need to do this twice; if so, choose "Overwrite."

Xcode Tools

Apple's developer tools (aka Xcode Tools) may have been installed with your operating system. If typing "which gcc" in a terminal window produces "/usr/bin/gcc" then the tools are probably installed. The remainder of this installation worked for me using Xcode Tools 1.5; you may want to get this version if yours is older. The package is freely available at the Apple Developer Connection. You need to join ADC, but joining is free. Select all optional packages when installing (by choosing customize).


A Fortran compiler g77 is available from Guarav Khanna's High Performance Computing for Mac OSX site. Download the Panther binary (version 3.4). Then in a terminal window cd to the download directory and type:

    gunzip g77v3.4-bin.tar.gz (only if your browser didn't gunzip)
    sudo tar -xvf g77v3.4-bin.tar -C / 

This installs everything in /usr/local.

FFTW Libraries

FFTW is a C subroutine library for performing fast Fourier transformations. Download version 2.1.5. In a terminal window cd to the installation directory and type:

    gunzip fftw-2.1.5.tar.gz (if your browser didn't gunzip)
    tar -xvf fftw-2.1.5.tar 
    cd fftw-2.1.5
    sudo make install


F2PY - the Fortran to Python interface generator lets SciPy build wrappers that allow the use of Fortran code to carry out computationally intensive tasks. Download and install in a terminal window by:

    tar -xvzf F2PY-2-latest.tar.gz
    cd  F2PY*1 (replace 1 by the last digit of the gunzipped directory)
    sudo python install


AquaTerm is a graphics terminal used to display plots. Download aquaterm-1.0.a2.tar.gz and install as follows:

    Drag to /Applications
    In a terminal window cd to the download directory and type the commands:
      sudo cp ./lib/libaquaterm.1.0.0.dylib /usr/local/lib/
      sudo ln -s /usr/local/lib/libaquaterm.1.0.0.dylib /usr/local/lib/libaquaterm.dylib
      cp -rf ./include /usr/local/include/aquaterm
Start Aquaterm once by hand (from /Applications/Aquaterm); this appears to be necessary for automatic calls to work later.


Gnuplot is a high quality open-source plotting package that can be used on its own or by calls from within Python. Download gnuplot version 4.0.0 and untar it:

    tar -xvzf gnuplot-4.0.0.tar.gz

In a terminal type:
    cd gnuplot-4.0.0
    sudo make install

Test Gnuplot by issuing the command "gnuplot" in a terminal window; once gnuplot starts, type
   gnuplot> set terminal aqua
   gnuplot> plot sin(x)
This should pop up an Aquaterm window with a plot.

Calling Gnuplot from Python

Using lets you call Gnuplot from within Python. Download and then in a terminal window cd to the download directory and type

    gunzip gnuplot-py-1.7.tar (if the file was not uncompressed during download)
    tar -xf gnuplot-py-1.7.tar (if the file was not untarred during download)
    cd gnuplot-py-1.7
    sudo python install

You need to fix one file which this installs. In a terminal change directory by issuing the command

    cd /Library/Python/2.3/Gnuplot
Edit the file (perhaps using "pico"), changing the line
    gnuplot_command = 'gnuplot'
    gnuplot_command = '/usr/local/bin/gnuplot'


SciPy is an open-source library of scientific tools for Python. Check out the source files from the CVS repository (see CVS documentation). This creates a directory scipy. In that directory is a file that needs one change. Edit this file as follows (perhaps by the command "pico") to disable xplt by adding it to the ignore_packages list at the end of the file. That is, replace:

    ignore_packages = [
        # list of package names that will not be built.
    ignore_packages = [
(Thanks to Chris Fonnesbeck for explaining this.) Then in a terminal window type:
    python build
    sudo python install

Using Gnuplot within Python

To test Gnuplot, start PythonIDE. Open the file /Library/Python/2.3/Gnuplot/ using File->Open. The file opens in PythonIDE's script editor. Look at the file to see typical uses of Click the little black triangle on the upper right edge of the PythonIDE window that opens, and choose "Run as __main__". Then click "Run all". Wait a while before clicking "OK".

The examples in all plot in the same window. You can open plots in multiple windows using:

    g('set terminal aqua 1')
    g('set terminal aqua 2')
M.D. Johnson, October 18, 2004