I don't think changing the contents of /usr/include (as suggested in another answer, and in other similar threads) is a good idea in general; that's Apple's "property." A similar question on StackOverflow, in the context of a Homebrew installation, instead recomments linking within /usr/local/include, which is safer, but still probably not a good idea, since Homebrew maintains that.
I think a better solution is to follow the matplotlib installation instructions and use a setup.cfg file to specify the locations of resources that aren't where it expects them. To do this while letting pip manage the installation:
Download the mpl source and unpack it into DIR (e.g., DIR=matplotlib-1.3.1).
cd DIR
, copy 'setup.cfg.template' to 'setup.cfg', and edit the directories section to look like the following (assuming you've installed freetype2 into /usr/local, e.g., via Homebrew):[directories] # Uncomment to override the default basedir in setupext.py. # This can be a single directory or a comma-delimited list of directories. #basedirlist = /usr basedirlist = /usr/local/include/freetype2/
Build matplotlib in-place (but don't install it) via:
python setup.py build_ext
(takes about a minute on my MacBook Pro).Install with pip from within that directory:
pip install .
(note the dot!).
Pip will recognize it as matplotlib and index appropriately.
I already had mpl's dependencies installed when I did this, so I'm not sure whether missing some of them complicates this.