Skip to main content
 首页 » 编程设计

python之python 3.5 的 matplotlib 安装错误

2024年10月24日14sky-heaven

我正在尝试使用 Python 3.5 在 OS X Yosemite 上安装 matplotlib。已经安装的包是:

appnope (0.1.0) 
decorator (4.0.2) 
gnureadline (6.3.3) 
ipython (4.0.0) 
ipython-genutils (0.1.0) 
nose (1.3.7) 
numpy (1.9.2) 
pandas (0.16.2) 
path.py (8.1.1) 
pbr (1.8.0) 
pexpect (3.3) 
pickleshare (0.5) 
pip (7.1.2) 
Pygments (2.0.2) 
python-dateutil (2.4.2) 
pytz (2015.4) 
pyzmq (14.7.0) 
scipy (0.16.0) 
setuptools (18.3.1) 
simplegeneric (0.8.1) 
six (1.9.0) 
stevedore (1.8.0) 
sympy (0.7.6.1) 
traitlets (4.0.0) 
virtualenv (13.1.2) 
virtualenv-clone (0.2.6) 
virtualenvwrapper (4.7.1) 
wheel (0.24.0) 

此外

freetype-config --version 18.0.12 

我已经通过 Macport 安装了 freetype

但是我不断收到以下错误:

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/_t/n0g5nl692778w02hdlnf127h0000gn/T/pip-build-82786k0f/matplotlib 

我在安装命令后收到的完整信息是:

 pip3 install matplotlib 
 
Collecting matplotlib 
  Using cached matplotlib-1.4.3.tar.gz 
    Complete output from command python setup.py egg_info: 
    IMPORTANT WARNING: 
        pkg-config is not installed. 
        matplotlib may not be able to find some of its dependencies 
    ============================================================================ 
    Edit setup.cfg to change the build options 
 
    BUILDING MATPLOTLIB 
                matplotlib: yes [1.4.3] 
                    python: yes [3.5.0 (v3.5.0:374f501f4567, Sep 12 2015, 
                            11:00:19)  [GCC 4.2.1 (Apple Inc. build 5666) (dot 
                            3)]] 
                  platform: yes [darwin] 
 
    REQUIRED DEPENDENCIES AND EXTENSIONS 
                     numpy: yes [version 1.9.2] 
                       six: yes [using six version 1.9.0] 
                  dateutil: yes [using dateutil version 2.4.2] 
                      pytz: yes [using pytz version 2015.4] 
                   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 [Official versions of PyCXX are not compatible 
                            with matplotlib on Python 3.x, since they lack 
                            support for the buffer object.  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 [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.3.7 / using unittest.mock] 
            toolkits_tests: yes [using nose version 1.3.7 / using unittest.mock] 
 
    OPTIONAL BACKEND EXTENSIONS 
                    macosx: yes [installing, darwin] 
                    qt5agg: no  [PyQt5 not found] 
                    qt4agg: no  [PyQt4 not found] 
                    pyside: no  [PySide 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 version not identified] 
                     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: yes [version 1.15] 
               ghostscript: yes [version 9.16] 
                     latex: yes [version 3.14159265] 
                   pdftops: no 
 
    ============================================================================ 
                            * The following required packages can not be built: 
                            * freetype 
 
    ---------------------------------------- 

请您参考如下方法:

您似乎还没有安装 pkg-config。

只需通过 brew 安装即可:

brew install pkg-config 

为了安全起见,还要安装未解析的依赖项:

pip3 install tornado pyparsing