October 26, 2012

How to install matplotlib on Mac OS X Lion

I was struggeling with installation of matplotlib on Mac OS X Lion. While trying to pip install matplotlib I saw a lot of bad stuff like

src/ft2font.h:16:22: error: ft2build.h: No such file or directory
src/ft2font.h:17:10: error: #include expects "FILENAME" or <FILENAME>
...
lipo: can't open input file: /var/tmp//ccuS7mkF.out (No such file or directory)
error: command 'llvm-gcc-4.2' failed with exit status 1

It seemed that that issue was caused by

REQUIRED DEPENDENCIES
	numpy: 1.5.1
    freetype2: found, but unknown version (no pkg-config)
    	* WARNING: Could not find 'freetype2' headers in any
    	* of '.', './freetype2'.

So I went and recompiled the latest freetype (2.1.10)

./configure
make
sudo make install

That however did not solve my problem. So after futher investigation I found that luckily I was not alone and as always, there is a hint at stackoverflow.

Most of the symlinks were there already so for me the success followed after:

sudo ln -s /usr/X11/include/png.h /usr/local/include/png.h
sudo ln -s /usr/X11/include/pngconf.h /usr/local/include/pngconf.h
sudo ln -s /usr/X11/include/pnglibconf.h /usr/local/include/pnglibconf.h
sudo ln -s /usr/X11/lib/libpng.dylib /usr/local/lib/libpng.dylib
sudo ln -s freetype2/freetype/ freetype
sudo pip install matplotlib

Powered by Hugo & Kiss.