Matplotlib在Mac OSX 10.8 Mountain Lion上安装失败

use*_*163 26 matplotlib

我试图在我的MacBook Air上安装matplotlib,但它总是给我这个错误信息:

 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**
Run Code Online (Sandbox Code Playgroud)

我尝试使用自制软件安装freetype和libpng,但它不起作用.我怎样才能获得ft2build.h?

Мат*_*нер 36

下面根据来自指示安装Python后就职于matplotlib安装thegreenroom.安装Python后,这些说明对我不起作用.我按照Scipy.org的说明安装了numpy和scipy.然后我做了(改编自上面的答案):

brew install freetype
brew install libpng
Run Code Online (Sandbox Code Playgroud)

但是,无论是安装pip install matplotlib还是尝试从源代码安装,我都收到了相同的错误消息

python setup.py build
python setup.py install
Run Code Online (Sandbox Code Playgroud)

在我通过克隆的matplotlib目录中git clone https://github.com/matplotlib/matplotlib.git.

错误一直持续到我跑了

brew link freetype
Run Code Online (Sandbox Code Playgroud)

然后从克隆的matplotlib目录中运行

python setup.py build
python setup.py install
Run Code Online (Sandbox Code Playgroud)

安装成功了.


Cyr*_*rus 25

这可能有助于人们寻找非自制的解决方案.

我的目标:pip install用于为非系统python 2.7.3构建构建matplotlib.

截至2013年2月,使用最新的X-Code和X-Code命令行工具,无论我尝试过什么样的体操,在使用gcc编译ft2build时,我总是收到与C++ ostream相关的模板错误.

我能够获得一个pip安装来使用以下环境变量:

export CC=clang
export CXX=clang++
export LDFLAGS="-L/usr/X11/lib"
export CFLAGS="-I/usr/X11/include -I/usr/X11/include/freetype2"
Run Code Online (Sandbox Code Playgroud)

我只是强迫clang并添加了我的xquartz路径.没有额外的pkg-config或libpng构建,没有sudo-ed符号链接.


mat*_*ski 8

我认为其他答案都在正确的轨道上,但我遇到了同样的问题,可以证明:

brew install pkg-config
brew install freetype
pip install matplotlib
Run Code Online (Sandbox Code Playgroud)

会产生相同的结果.通常在Ubuntu盒子上我的下一个响应就是

sudo apt-get install libfreetype-dev
Run Code Online (Sandbox Code Playgroud)

或者安装标题的一些变体.但是,我找不到这样的自制软件包.此外,我能够在我的系统上一个非常正常的位置找到有问题的头文件:

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
Run Code Online (Sandbox Code Playgroud)

所以我怀疑我的系统路径有问题,或者使用自制软件包matplotlib.由于我很懒,我只是尝试从github安装matplotlib包头:

pip install git+git://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev
Run Code Online (Sandbox Code Playgroud)

它对我有用.

  • pkg-config对我来说是个缺失的部分.一旦我安装了它,一切都开始工作了. (4认同)

Jou*_*nen 2

请注意“no pkg-config”通知。您的搜索路径上应该有pkg-config,并且它可能需要是自制版本,以便它知道库的自制版本在哪里。