A mind that is stretched by a new experience can never go back to its old dimensions.

Installing matplotlib on Mac OSX

December 24th, 2010 Posted in geek out, popular

I have had a god-awful time installing matplotlib for Mac OSX. I thought it was going to be easy to port my python development environment from Ubuntu to my new(ish) macbook pro, but NO.

I found myself googling errors like:
matplotlib tar: unrecognized archive format: inappropriate file type or format
(when the matplotlib make file had incorrect args for an untar of libpng)

no module named matplotlib.pyplot
(when an incorrect version of matplotlib was installed)

matplotlib ImportError: No module named ma
(when an incorrect version, 0.91 of matplotlib was installed)

matplotlib lipo: can’t open input file: /var/folders/8e/8efpckbcfb4dgr+x8n3urk+++tq/-tmp-//ccczosb6.out (no such file or directory)
(when baby jesus didn’t come on time)

matplotlib requires system python 2.6 to install
(when trying to install from dpkg)

and several other problems.

HERE IS HOW I GOT IT TO WORK
1. Install freetype2
– get freetype from http://gnu.mirrors.pair.com/savannah/savannah/freetype/freetype-2.4.4.tar.gz , which is the most current as of 12-2010
– a standard install:
./configure
make
sudo make install
2. Install libpng
– get libpng from http://ethan.tira-thompson.com/Mac_OS_X_Ports.html
– a standard install:
./configure
make
sudo make install
3. Install matplotlib from source
– get matplotlib version > 0.9. version 0.9 is totally out of date and should not be used
do not use “pip install matplotlib”. matplotlib developers have not properly updated their link with pypi, and “pip install matplotlib” will install the OLD and USELESS version of matplotlib.
– Instead, get the source from: http://superb-sea2.dl.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0/matplotlib-1.0.0.tar.gz
– python setup.py build
At this point, it MUST recognize your freetype2 with the correct version:
REQUIRED DEPENDENCIES
numpy: 1.2.1
freetype2: 12.2.6

If it continues without a real version number beside freetype2, it WILL FAIL. I don’t know why the installer continues, as it certainly should not. If a matplotlib developer reads this, please correct!
– If this step finishes without errors, you’re golden
– python setup.py install

and you’re golden!

I have burned 3 hours on this sh** when I should have been writing my thesis. Hope this helps others out there.

  1. 6 Responses to “Installing matplotlib on Mac OSX”

  2. By Ustun OzgurNo Gravatar on Jan 21, 2011

    Thanks a lot. It saved me time. pip install still doesn’t work.

  3. By Matt BennettNo Gravatar on May 13, 2011

    This was useful, thanks. A few extra points:

    1) I needed pkg-config before the matplotlib build process would find a version number for freetype2 and libpng

    2) matplotkit wouldn’t build against libpng-1.5.0; in the end I installed the 1.4.5 binary from http://ethan.tira-thompson.org/Mac_OS_X_Ports.html which solved the problem.

    3) The usual pip install process is still broken, but you can make it work by specifying the source using the -f option, e.g. “pip install -f http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0.1/matplotlib-1.0.1.tar.gz matplotlib”

  4. By Jimi FordNo Gravatar on Aug 17, 2012

    Step 2 link is now http://ethan.tira-thompson.com/Mac_OS_X_Ports.html

    .org gives a 404 error

  5. By heartlessNo Gravatar on Nov 11, 2012

    Grab the dmg from https://github.com/matplotlib/matplotlib/downloads
    click and done.

  6. By Matías HerranzNo Gravatar on May 6, 2013

    Thanks a lot! It saved me hours!
    Matías Herranz recently posted..Working on django-notification (django 1.4 support, internationalization, etc.).

  7. By Tyler WilcoxNo Gravatar on Jun 9, 2016

    You just saved me hours of further frustration and failure. Thank you so much!

Post a Comment

CommentLuv badge