Matplotlib install failure on Mac OSX 10.8 Mountain Lion

前端 未结 11 958
眼角桃花
眼角桃花 2020-12-23 02:21

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         


        
相关标签:
11条回答
  • 2020-12-23 02:48

    Here's the brew + pip recipe I used from a cold start. If you already have python and gfortran and such, jump in at the point where you need. The crucial steps appear to be brew install freetype and brew install libpng prior to doing pip install matplotlib

    $ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
    $ brew doctor
    $ brew install python
    $ export PATH=/usr/local/bin:/usr/local/share/python:$PATH
    $ easy_install pip
    $ brew install gfortran
    $ pip install numpy
    $ pip install scipy
    $ brew install pkg-config
    $ brew install freetype
    $ brew install libpng
    $ pip install matplotlib
    $ python
    >>> import numpy
    >>> import scipy
    >>> import matplotlib
    
    0 讨论(0)
  • 2020-12-23 02:49

    I think the other answers are on the right track, but I encountered this same problem and can attest that:

    brew install pkg-config
    brew install freetype
    pip install matplotlib
    

    would yield the same result. Typically on an Ubuntu box my next response would have been

    sudo apt-get install libfreetype-dev
    

    or some variation of that to install the header. However, I could find no such homebrew package. Furthermore, I was able to locate the header file in question in a pretty normal location on my system:

    zoidberg:~ matt$ locate ft2build.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include/ft2build.h
    /usr/X11/include/ft2build.h
    

    So I suspect there's either a problem with my system paths or with the homebrew packaged matplotlib. Since I'm lazy, I just tried installing the matplotlib package head from github:

    pip install git+git://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev
    

    and it worked for me.

    0 讨论(0)
  • 2020-12-23 02:50

    You need freetype:

    brew install freetype
    

    See the following:

    http://comments.gmane.org/gmane.comp.python.matplotlib.general/31394

    0 讨论(0)
  • 2020-12-23 02:55

    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.

    0 讨论(0)
  • 2020-12-23 02:56

    Note the 'no pkg-config' notices. You should have pkg-config on your search path, and it presumably needs to be the homebrew version so that it knows where the homebrew versions of the libraries are.

    0 讨论(0)
  • 2020-12-23 02:56

    I have found installing these pacakges via homebrew to be the most reliable method

     # if you haven't installed python via brew already:
     brew install python
    
     # sets up python as default python instead of system python
     brew link python
    
     # Add more brew formulae so we can install our py libs with brew
     brew tap samueljohn/python
     brew tap homebrew/science
    
     # install numpy,scipy,matplotlib and dependencies ( gfortran, etc.. )
     brew install numpy
     brew install scipy
     brew insatll matplotlib
    
    0 讨论(0)
提交回复
热议问题