Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib install failure on Mac OSX 10.8 Mountain Lion

Tags:

matplotlib

I tried to install matplotlib on my MacBook Air, but it always gives me this error message:

 Processing matplotlib-1.1.1_notests.tar.gz
 Running matplotlib-1.1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-3jFpXK/matplotlib-1.1.1/egg-dist-tmp-jC7QY3
    basedirlist is: []
    ============================================================================
    BUILDING MATPLOTLIB
                matplotlib: 1.1.1
                    python: 2.7.2 (default, Jun 20 2012, 16:23:33)  [GCC 4.2.1
                            Compatible Apple Clang 4.0
                            (tags/Apple/clang-418.0.60)]
                  platform: darwin

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

    OPTIONAL BACKEND DEPENDENCIES
                    libpng: found, but unknown version (no pkg-config)
                            * Could not find 'libpng' headers in any of '.'
                   Tkinter: Tkinter: version not identified, Tk: 8.5, Tcl: 8.5
                      Gtk+: no
                            * Building for Gtk+ requires pygtk; you must be able
                            * to "import gtk" in your build/install environment
           Mac OS X native: yes
                        Qt: no
                       Qt4: no
                    PySide: no
                     Cairo: no

    OPTIONAL DATE/TIMEZONE DEPENDENCIES
                  datetime: present, version unknown
                  dateutil: 1.5
                      pytz: matplotlib will provide
    adding pytz

    OPTIONAL USETEX DEPENDENCIES
                    dvipng: 1.14
               ghostscript: 9.05
                     latex: 3.1415926

    [Edit setup.cfg to suppress the above messages]




  pymods ['pylab']
    packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz']
    warning: no files found matching 'KNOWN_BUGS'
    warning: no files found matching 'INTERACTIVE'
    warning: no files found matching 'MANIFEST'
    warning: no files found matching '__init__.py'
    warning: no files found matching 'examples/data/*'
    warning: no files found matching 'lib/mpl_toolkits'
    warning: no files found matching 'LICENSE*' under directory 'license'
    clang: warning: argument unused during compilation: '-mno-fused-madd'
    In file included from src/ft2font.cpp:3:
    src/ft2font.h:16:10: fatal error: 'ft2build.h' file not found

**#include <ft2build.h>
             ^
    1 error generated.
    error: Setup script exited with error: command 'clang' failed with exit status 1**

I tried to install freetype and libpng using homebrew but it doesn't work. How can I get ft2build.h?

like image 767
user694163 Avatar asked Sep 11 '12 05:09

user694163


2 Answers

The following worked for matplotlib installation after installing python according to instructions from thegreenroom. Those instructions didn't work for me after I installed Python. I followed the instructions from Scipy.org to install numpy and scipy. Then I did (adapted from above answer):

brew install freetype
brew install libpng

However I got the same error message whether I installed with pip install matplotlib or trying to install from source, doing

python setup.py build
python setup.py install

in the matplotlib directory I cloned via git clone https://github.com/matplotlib/matplotlib.git.

The error persisted until I ran

brew link freetype

Then from the cloned matplotlib directory I ran

python setup.py build
python setup.py install

And the installation succeeded.

like image 177
Matthew Turner Avatar answered Nov 14 '22 03:11

Matthew Turner


This may help folks looking for a non-homebrew solution.

My goal: use pip install to build matplotlib for a non-system python 2.7.3 build.

Using latest X-Code and X-Code command line tools as of Feb 2013, no matter what gymnastics I tried, I always received C++ ostream related template errors when compiling ft2build with gcc.

I was able to get a pip install to work with the following env vars:

export CC=clang
export CXX=clang++
export LDFLAGS="-L/usr/X11/lib"
export CFLAGS="-I/usr/X11/include -I/usr/X11/include/freetype2"

I simply forced clang and added my xquartz paths. No extra pkg-config or libpng builds, no sudo-ed symlinks.

like image 26
Cyrus Avatar answered Nov 14 '22 03:11

Cyrus