【问题标题】:Upgrading matplotlib to 1.5 on OS X 10.11 fails because of freetype由于 freetype,在 OS X 10.11 上将 matplotlib 升级到 1.5 失败
【发布时间】:2015-12-14 13:53:35
【问题描述】:

一个简单的

sudo pip install matplotlib --upgrade

失败并显示以下日志:

Downloading/unpacking matplotlib from https://pypi.python.org/packages/source/m/matplotlib/matplotlib-1.5.0.tar.gz#md5=7952a539418ed77432aa4727409f24cf
  Running setup.py egg_info for package matplotlib
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [1.5.0]
                    python: yes [2.7.3 |EPD 7.3-2 (64-bit)| (default, Apr 12
                            2012, 11:14:05)  [GCC 4.0.1 (Apple Inc. build
                            5493)]]
                  platform: yes [darwin]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.10.1]
                  dateutil: yes [using dateutil version 2.4.2]
                      pytz: yes [using pytz version 2015.7]
                    cycler: yes [cycler was not found. pip will attempt to
                            install it after matplotlib.]
                   tornado: yes [using tornado version 2.2]
                 pyparsing: yes [Your pyparsing contains a bug that will be
                            monkey-patched by matplotlib.  For best results,
                            upgrade to pyparsing 2.0.1 or later.]
                    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 [version 1.6.18]
                     qhull: yes [pkg-config information for 'qhull' could not be
                            found. Using local copy.]

    OPTIONAL SUBPACKAGES
               sample_data: yes [installing]
                  toolkits: yes [installing]
                     tests: yes [using nose version 1.1.2 / mock is required to
                            run the matplotlib test suite. "setup.py test" will
                            automatically download it. Install mock to run
                            matplotlib.test()]
            toolkits_tests: yes [using nose version 1.1.2 / mock is required to
                            run the matplotlib test suite. "setup.py test" will
                            automatically download it. Install mock to run
                            matplotlib.test()]

    OPTIONAL BACKEND EXTENSIONS
                    macosx: yes [installing, darwin]
                    qt5agg: no  [PyQt5 not found]
                    qt4agg: yes [installing, Qt: 4.7.3, PySide: 1.1.0; PyQt4 not
                            found]
                   gtk3agg: no  [Requires pygobject to be installed.]
                 gtk3cairo: no  [Requires cairocffi or pycairo 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  [cairocffi or pycairo not found]
                 windowing: no  [Microsoft Windows only]

    OPTIONAL LATEX DEPENDENCIES
                    dvipng: no
               ghostscript: yes [version 9.16]
                     latex: no
                   pdftops: no

    OPTIONAL PACKAGE DATA
                      dlls: no  [skipping due to configuration]

    ============================================================================
                            * 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.5.0]

                python: yes [2.7.3 |EPD 7.3-2 (64-bit)| (default, Apr 12

                        2012, 11:14:05)  [GCC 4.0.1 (Apple Inc. build

                        5493)]]

              platform: yes [darwin]



REQUIRED DEPENDENCIES AND EXTENSIONS

                 numpy: yes [version 1.10.1]

              dateutil: yes [using dateutil version 2.4.2]

                  pytz: yes [using pytz version 2015.7]

                cycler: yes [cycler was not found. pip will attempt to

                        install it after matplotlib.]

               tornado: yes [using tornado version 2.2]

             pyparsing: yes [Your pyparsing contains a bug that will be

                        monkey-patched by matplotlib.  For best results,

                        upgrade to pyparsing 2.0.1 or later.]

                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 [version 1.6.18]

                 qhull: yes [pkg-config information for 'qhull' could not be

                        found. Using local copy.]



OPTIONAL SUBPACKAGES

           sample_data: yes [installing]

              toolkits: yes [installing]

                 tests: yes [using nose version 1.1.2 / mock is required to

                        run the matplotlib test suite. "setup.py test" will

                        automatically download it. Install mock to run

                        matplotlib.test()]

        toolkits_tests: yes [using nose version 1.1.2 / mock is required to

                        run the matplotlib test suite. "setup.py test" will

                        automatically download it. Install mock to run

                        matplotlib.test()]



OPTIONAL BACKEND EXTENSIONS

                macosx: yes [installing, darwin]

                qt5agg: no  [PyQt5 not found]

                qt4agg: yes [installing, Qt: 4.7.3, PySide: 1.1.0; PyQt4 not

                        found]

               gtk3agg: no  [Requires pygobject to be installed.]

             gtk3cairo: no  [Requires cairocffi or pycairo 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  [cairocffi or pycairo not found]

             windowing: no  [Microsoft Windows only]



OPTIONAL LATEX DEPENDENCIES

                dvipng: no

           ghostscript: yes [version 9.16]

                 latex: no

               pdftops: no



OPTIONAL PACKAGE DATA

                  dlls: no  [skipping due to configuration]



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

                        * The following required packages can not be built:

                        * freetype

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/matplotlib
Storing complete log in /Users/vlad-arisolteanu/.pip/pip.log

同时,

brew install freetype

返回:

Warning: freetype-2.6_1 already installed

所以看起来我的系统上安装了 freetype。那么发生了什么?令人失望的是,像 matplotlib 这样关键的 Python 包没有安装。

任何帮助将不胜感激。

【问题讨论】:

  • 另一方面,ls -l /usr/include/freetype2/ft2build.h 找不到。
  • 您是否正在尝试将 matplotlib 安装到系统 Python 中?这似乎不是您将其安装到 brew 管理的 Python 中。
  • 我正在安装到 Enthought(当前设置为默认 Python 解释器)。
  • 由于您使用的是 Enthought,推荐安装 matplotlib 之类的方法是安装 Canopy Express。这是 Enthought 发行版的免费附加组件,它还允许您访问大约 100 个可以轻松安装到 Enthought 的软件包。您尝试对 brew 执行的操作不适用于 Enthought 开箱即用,并且需要您设置正确的环境变量和构建设置,因为整个系统不了解 brew 的存在.
  • @birryree 有效。请随意发布它作为答案,我会选择它!

标签: python matplotlib freetype


【解决方案1】:

由于您使用的是 Enthought,因此安装 matplotlib 之类的推荐方法是安装 Canopy Express,它是 Enthought 发行版的免费附加组件,还可以让您轻松访问大约 100 个软件包安装到 Enthought 中。

您尝试对 brew 执行的操作不适用于 Enthought 开箱即用,并且需要您设置正确的环境变量和构建设置,因为整个系统不了解 brew的存在。

【讨论】:

    【解决方案2】:

    您可能需要安装pkg-config。试试:

    brew install pkg-config
    

    在安装之前matplotlib

    有关此问题的更多讨论,请参阅here。听起来matplotlibfreetype 的路径感到困惑,但pkg-config 会覆盖它并设置正确的路径。还有matplotlib自述文件here,这表明您需要pkg-config

    【讨论】:

    • 我以前见过这个解决方案。但是 brew 返回Warning: pkg-config-0.29 already installed。另外,找不到ls -l /usr/include/freetype2/ft2build.h
    • 它是否存在于其他地方?例如/usr/local/Cellar/freetype/2.6.1/include/freetype2?如果是这样,你可以ln -s /usr/local/Cellar/freetype/2.6.1/include/freetype2 /usr/include/freetype
    • 谢谢,@birryree 现在已经回答了这个问题。更普遍的问题是我使用的 Python 解释器不是由 brew 管理的。
    【解决方案3】:

    我正在使用 matplotlib、OSX 10.11、Python 3.6 和 matplotlib 1.5.1

    make virtualenv(在没有空格的路径中) 我已经安装了 python 3,但我发现提供符号链接并没有安装它,所以我按照 symlink 到 python3.6 文件并使用它。使用virtualenv -p 命令。

    我安装了 xquartz 的东西,显然默认情况下不在 osx 中,matplotlib 仍然不会安装。也就是说,直到我发现matplotlib 安装的东西看起来在/include/ft2buid.h 中而不是在/include/freetype2/ft2build.h 中,所以我在库中设置了一个指向/freetype2/ft2build.h 文件的符号链接,然后运行 ​​pip install matplotlib 并且它工作了

    Python 没有作为框架安装……

    我尝试制作这个名为 framework python 的文件,该文件重新路由到 python 或其他东西,但没有奏效 最后我找到了一个注释,上面写着转到文件夹:

    ~/.matplotlib(逐字粘贴在转到文件夹对话中) 然后制作一个名为matplotlibrc(无文件扩展名)的纯文本文件,其中只有文本: 后端:TkAgg

    这就是我所说的 voodoo,现在 matplotlib 的雨演示工作

    这个特定的问题可能只需要一个符号链接位,我给自己增加了 virtualenv 的额外复杂性,但我不记得为什么了。

    【讨论】:

      猜你喜欢
      • 2016-01-21
      • 2016-04-09
      • 2016-09-08
      • 2015-12-26
      • 1970-01-01
      • 2014-01-11
      • 1970-01-01
      • 2016-07-27
      相关资源
      最近更新 更多