无法在Mac上安装Matplotlib

时间:2014-05-24 13:57:39

标签: python macos matplotlib

我无法在Mavericks 10.9上安装Matplotlib。我有以下错误消息告诉我无法构建freetype:

    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [1.3.1]
                    python: yes [2.7.6 (default, Apr  9 2014, 11:48:52)  [GCC
                            4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.38)]]
                  platform: yes [darwin]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.8.1]
                  dateutil: yes [dateutil was not found. It is required for date
                            axis support. pip/easy_install may attempt to
                            install it after matplotlib.]
                   tornado: yes [tornado was not found. It is required for the
                            WebAgg backend. pip/easy_install may attempt to
                            install it after matplotlib.]
                 pyparsing: yes [pyparsing was not found. It is required for
                            mathtext support. pip/easy_install may attempt to
                            install it after matplotlib.]
                     pycxx: yes [Couldn't import.  Using local copy.]
                    libagg: yes [pkg-config information for 'libagg' could not
                            be found. Using local copy.]
                  freetype: no  [The C/C++ header for freetype2 (ft2build.h)
                            could not be found.  You may need to install the
                            development package.]
                       png: yes [pkg-config information for 'libpng' could not
                            be found. Using unknown version.]

    OPTIONAL SUBPACKAGES
               sample_data: yes [installing]
                  toolkits: yes [installing]
                     tests: yes [nose 0.11.1 or later is required to run the
                            matplotlib test suite]

    OPTIONAL BACKEND EXTENSIONS
                    macosx: yes [installing, darwin]
                    qt4agg: no  [PyQt4 not found]
                   gtk3agg: no  [Requires pygobject to be installed.]
                 gtk3cairo: no  [Requires cairo to be installed.]
                    gtkagg: no  [Requires pygtk]
                     tkagg: yes [installing, version 81008]
                     wxagg: no  [requires wxPython]
                       gtk: no  [Requires pygtk]
                       agg: yes [installing]
                     cairo: no  [cairo not found]
                 windowing: no  [Microsoft Windows only]

    OPTIONAL LATEX DEPENDENCIES
                    dvipng: no
               ghostscript: no
                     latex: no
                   pdftops: no

    ============================================================================
                            * The following required packages can not be built:
                            * freetype
    Complete output from command python setup.py egg_info:
    ============================================================================

Edit setup.cfg to change the build options



BUILDING MATPLOTLIB

            matplotlib: yes [1.3.1]

                python: yes [2.7.6 (default, Apr  9 2014, 11:48:52)  [GCC

                        4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.38)]]

              platform: yes [darwin]



REQUIRED DEPENDENCIES AND EXTENSIONS

                 numpy: yes [version 1.8.1]

              dateutil: yes [dateutil was not found. It is required for date

                        axis support. pip/easy_install may attempt to

                        install it after matplotlib.]

               tornado: yes [tornado was not found. It is required for the

                        WebAgg backend. pip/easy_install may attempt to

                        install it after matplotlib.]

             pyparsing: yes [pyparsing was not found. It is required for

                        mathtext support. pip/easy_install may attempt to

                        install it after matplotlib.]

                 pycxx: yes [Couldn't import.  Using local copy.]

                libagg: yes [pkg-config information for 'libagg' could not

                        be found. Using local copy.]

              freetype: no  [The C/C++ header for freetype2 (ft2build.h)

                        could not be found.  You may need to install the

                        development package.]

                   png: yes [pkg-config information for 'libpng' could not

                        be found. Using unknown version.]



OPTIONAL SUBPACKAGES

           sample_data: yes [installing]

              toolkits: yes [installing]

                 tests: yes [nose 0.11.1 or later is required to run the

                        matplotlib test suite]



OPTIONAL BACKEND EXTENSIONS

                macosx: yes [installing, darwin]

                qt4agg: no  [PyQt4 not found]

               gtk3agg: no  [Requires pygobject to be installed.]

             gtk3cairo: no  [Requires cairo to be installed.]

                gtkagg: no  [Requires pygtk]

                 tkagg: yes [installing, version 81008]

                 wxagg: no  [requires wxPython]

                   gtk: no  [Requires pygtk]

                   agg: yes [installing]

                 cairo: no  [cairo not found]

             windowing: no  [Microsoft Windows only]



OPTIONAL LATEX DEPENDENCIES

                dvipng: no

           ghostscript: no

                 latex: no

               pdftops: no



============================================================================

                        * The following required packages can not be built:

                        * freetype

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /private/var/folders/jj/0w0dd3n16jq4g5579g6c7h040000gn/T/pip_build_mc/matplotlib
Storing debug log for failure in /Users/mc/.pip/pip.log

我已按照herehere的说明操作,但仍然无效。这是一个干净的系统安装,我也只是用brew安装了Python。

4 个答案:

答案 0 :(得分:12)

我必须用brew安装pkg-config来修复它

    brew install freetype
    brew install pkg-config

' brew list'现在报道:

    freetype    libpng      pkg-config

答案 1 :(得分:2)

使用home-brew python安装Matplotlib。这终于为我解决了这个问题:

brew tap Homebrew/python  # installs the Homebrew/python "tap"
brew install matplotlib   # install matplotlib with homebrew

此处有更多信息:https://github.com/Homebrew/homebrew-python

答案 2 :(得分:0)

我认为问题是brew安装的freetype的标头不在matplotlib构建搜索的路径中。我遇到过同样的问题。尝试

ln -s /usr/local/opt/freetype/include/freetype2 /usr/local/include/freetype

答案 3 :(得分:0)

我还要安装pkg-config

brew install freetype
brew install pkg-config

除此之外,我得到了同样的错误。当我再次运行brew install freetype时,它说“警告:已经安装了freetype-2.7.1,它只是没有链接。”

我通过运行以下行来解决这个问题:

brew link libpng freetype