I just got matplotlib working on my box, so I thought I'd post this, so that it will be in the archives, and because I'd like others to try it and let me know if it doesn't work for you.
One question for the knowledgeable folks here:
I have /usr/include/zlib.h on my system, but I have no idea where I got it. I do know that it isn't on other systems in my office without the dev tools. Did it come with the dev tools, or something else I installed?
Anyway, here's what worked for me:
Installing matplotlib on OS-X (10.3.7)
Here are my notes as to what it took to get matplotlib (0.71) installed and working on OS-X. I have so far kept a fink-free system, so that's what I've done here as well. I use it with the AGG back end for generating images for a web site, and hopefully with the wx backend for interactive use and embedding in wx Applications.
According to the matplotlib install docs (http://matplotlib.sourceforge.net/installing.html), you need the following:
freetype (>= 2.1.7)
Personally, I've been avoiding Fink, as it doesn't seem to play well with the rest of OS-X, including the Apple supplied Python, so I've looked elsewhere for these libs.
I seem to have it in:
I don't think I installed it myself, so it probably came with Apple's X11, Which I did install.
However, I seemed to be having problems with that version, so I looked, and it seems to be:
Given that freetype2 is currently at version 2.1.9, I have no idea what to make of that! So off to sourceforge to get a new freetype:
where I got:
Following the instructions in docs/INSTALL.UNX:
$ sudo make install
That puts it in /usr/local/..., which is a good place for it.
I don't know where I might have gotten it, but there it is.
NOTE: I checked on another system in my office, and it doesn't have zlib. It also doesn't have any developer tools installed, so you couldn't build anything on it anyway. If zlib comes with XCode tools, anyone who can build should have it. It also may have come with some other package I've installed, but I have no idea what. Let me know if you know.
This, I didn't have on my system, except inside the wxWidgets source tree, so I went looking for it.
Note that you need zlib to compile libpng, so make sure you have that first.
I did a google search for "libpng OS-X". I found:
Which led me to the libpng sourceforge site.
From there I downloaded:
unpacked it, and opened a terminal in the libpng-1.2.8 directory, and did:
$ cp scripts/makefile.darwin ./makefile
(note that according to the INSTALL, there is supposed to be a makefile.macosx, but it wasn't there)
I took a look in the makefile, and found:
Which is not where zlib is on my system. However, while I can find zlib.h, I couldn't fine the actual lib, so I tried make without changing anything.
Which seemed to work fine. zlib must be installed in a standard location, and gcc found it.
$ sudo make install
to install the lib into /usr/local/ (this was specified in the makefile, and it's a good place for it)
$ make test
$ ./pngtest pngnow.png
Which both seemed to pass.
d) Numeric or numarray:
I already have Numeric installed, from Bob Ippolito's PIMP (MacPython Package Manager) repostitory. (www.undefined.org/python)
2) Building matplotlib
First, I took a look at the matplotlib setup.py. It had "auto" for the back-end flags, so I thought I would give it a try that way:
$python setup.py build
$ sudo python setup.py install
4) And now to test!
>>> import pylab
Could not open font file /Library/Fonts/NISC18030.ttf
No module named pygtk
PyGTK version 1.99.16 or greater is required to run the GTK Matplotlib backends
This turns out to be because the matlabrc file sets the GTKAgg back end as the default. You have two choices.
1) you can set the back end before importing pylab.
>>> import matplotlib
>>> import pylab
This works fine
2) Edit the matplotlibrc file. I found it in:
Change the line:
backend : GTKAgg # the default backend
backend : Agg # the default backend
And you're all set to make images for the web, etc.
I'm going to leave getting it to work with wxPython for another day.
Christopher Barker, Ph.D.
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception