Compile Matplotlib for Python on Snow Leopard


I've killed half a day trying to compile matplotlib for python on Snow Leopard. I've used the googles and found this helpful page ( but I still can't get it to compile. I see comments from other users on that page, so I know I'm not alone.

I already installed zlib, libpng and freetype independently.

I edited the make.osx file to contain this at the top:



## You shouldn't need to configure past this point

CFLAGS="-Os -arch x86_64 -arch i386 -I${PREFIX}/include"
LDFLAGS="-arch x86_64 -arch i386 -L${PREFIX}/lib"
CFLAGS_DEPS="-arch i386 -arch x86_64 -I${PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX10.6.sdk"
LDFLAGS_DEPS="-arch i386 -arch x86_64 -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX10.6.sdk"

I then run:

sudo make -f make.osx mpl_build

which gives me:

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" &&\
    export MACOSX_DEPLOYMENT_TARGET=10.6 &&\
    export CFLAGS="-Os -arch x86_64 -arch i386 -I/usr/local/include" &&\
    export LDFLAGS="-arch x86_64 -arch i386 -L/usr/local/lib" &&\
    python2.6 build

... snip ...

gcc-4.2 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -Os -arch x86_64 -arch i386 -I/usr/local/include -pipe -DPY_ARRAYAUNIQUE_SYMBOL=MPL_ARRAY_API -I/Library/Python/2.6/site-packages/numpy/core/include -I. -I/Library/Python/2.6/site-packages/numpy/core/include/freetype2 -I./freetype2 -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c src/ft2font.cpp -o build/temp.macosx-10.6-universal-2.6/src/ft2font.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++
In file included from src/ft2font.h:13,
                 from src/ft2font.cpp:1:
/usr/local/include/ft2build.h:56:38: error: freetype/config/ftheader.h: No such file or directory

... snip ...

src/ft2font.cpp:98: error: ‘FT_Int’ was not declared in this scope
/Library/Python/2.6/site-packages/numpy/core/include/numpy/__multiarray_api.h:1174: warning: ‘int _import_array()’ defined but not used
lipo: can't open input file: /var/tmp//ccDOGx37.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
make: *** [mpl_build] Error 1

I'm just lost.

9/25/2009 12:56:40 PM

Accepted Answer

According to your error message you have missing freetype headers. Can you locate them using system search functionalities. I will not lecture on using a pre-built package since I love scratching my head and compiling from the start as well.

9/25/2009 1:49:12 PM

This solution worked for me on OSX 10.8.3:

ln -s /usr/local/include/freetype2/freetype/ /usr/include/freetype

(Credit really goes to:

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow