BTW, whatever you do, do not follow the instructions that the matplotlib developers provide. You do not need another Python, including MacPython or the Endthought distribution or anything else..
To recap, matplotlib lists dependencies (in the
make.osx
file) of: libpng, libfreetype, and zlib. I read somewhere on the matplotlib site today (but can't find the link now) that zlib is not a required dependency. These days, the other two are actually provided by Apple:I'm not sure at the moment whether X11 came with Xcode (as it used to) or was present in the original Lion install.
In any case, I spent an hour or two trying to figure out how to use the build commands from the makefile that comes with matplotlib, but point at these libraries. In the process I found what appears to be a bug:
(and see Prashant's answer here), but we're going to use a different approach so it doesn't matter. I'm not sure how our method solved this in the end. As mentioned, the approach is to use Homebrew, in particular, something called
pkgconfig
. I used a Ruby script that downloads and installs Homebrew, as described here. The install gave this warning:These are, of course, the libraries we just installed in order to get matplotlib to build.
That's what got me working on the other method more seriously. I don't think the danger is all that great, but clearly it is better to use libraries that are (i) still available from the maintainers and (ii) have been vetted at least to some extent by other folks including Apple. AFAIK there aren't any known security issues with the versions we installed previously. I ripped them out anyway (they seemed to confuse
pkgconfig
).If we ask Homebrew for the libraries, it just points us to the ones we saw in
/usr/X11
:Following the instructions in the blog post I first installed
pkgconfig
:!!
That's all the Homebrew we need. This is followed by:
And we can see that I really did overwrite the first matplotlib install, and that we're actually using the libraries from /usr/X11, by first doing
Then when we run a script that imports
matplotlib.pyplot
, the Terminal shows (among much else) this:So that's what I'd recommend and it seems to be working fine. This simple script works exactly as you'd expect.
So the next thing to do is to figure out
pkgconfig
and Homebrew work their magic!P.S. You will still need to make and edit
~/.matplotlib
as discussed last time.