CentOS 7 安装matplotlib

PROBLEM

CentOS 7下 安装matplotlib。

pip install matplotlib

报错如下:

[root@localhost Desktop]# pip install matplotlib
Collecting matplotlib
  Using cached matplotlib-1.5.1.tar.gz
    Complete output from command python setup.py egg_info:
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [1.5.1]
                    python: yes [3.5.1 (default, Apr 15 2016, 00:15:43)  [GCC
                            4.8.5 20150623 (Red Hat 4.8.5-4)]]
                  platform: yes [linux]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.11.0]
                  dateutil: yes [dateutil was not found. It is required for date
                            axis support. pip/easy_install may attempt to
                            install it after matplotlib.]
                      pytz: yes [pytz was not found. pip will attempt to install
                            it after matplotlib.]
                    cycler: yes [cycler was not found. pip will 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.]
                    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: no  [pkg-config information for 'libpng' could not
                            be found.]
                     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 [nose 0.11.1 or later is required to run the
                            matplotlib test suite. Please install it with pip or
                            your preferred tool to run the test suite / using
                            unittest.mock]
            toolkits_tests: yes [nose 0.11.1 or later is required to run the
                            matplotlib test suite. Please install it with pip or
                            your preferred tool to run the test suite / using
                            unittest.mock]

    OPTIONAL BACKEND EXTENSIONS
                    macosx: no  [Mac OS-X only]
                    qt5agg: no  [PyQt5 not found]
                    qt4agg: no  [PySide not found; PyQt4 not found]
                   gtk3agg: no  [Requires pygobject to be installed.]
                 gtk3cairo: no  [Requires cairocffi or pycairo to be installed.]
                    gtkagg: no  [Requires pygtk]
                     tkagg: no  [TKAgg requires Tkinter.]
                     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.07]
                     latex: no
                   pdftops: yes [version 0.26.5]

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

    ============================================================================
                            * The following required packages can not be built:
                            * freetype, png

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-hlld4ja8/matplotlib/

大概意思是缺少一些依赖的包。有些依赖的包是python相关的,pip会自动安装。比如这句就是这个意思:

pip/easy_install may attempt to install it after matplotlib.

REASON

而有些依赖包则是pip解决不了的,需要yum来更新安装。比如这句:

freetype: no  [The C/C++ header for freetype2 (ft2build.h) could not be found. You may need to install the development package.]

SOLUTION

最终通过安装2个依赖包解决问题

sudo yum install freetype-devel
sudo yum install libpng-devel
sudo pip install matplotlib

RESULT

[root@localhost perrin]# pip install matplotlib
Collecting matplotlib
  Using cached matplotlib-1.5.1.tar.gz
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6 in /usr/local/lib/python3.5/site-packages (from matplotlib)
Collecting python-dateutil (from matplotlib)
  Downloading python_dateutil-2.5.2-py2.py3-none-any.whl (201kB)
    100% |████████████████████████████████| 204kB 23kB/s 
Collecting pytz (from matplotlib)
  Downloading pytz-2016.3-py2.py3-none-any.whl (479kB)
    100% |████████████████████████████████| 481kB 43kB/s 
Collecting cycler (from matplotlib)
  Downloading cycler-0.10.0-py2.py3-none-any.whl
Collecting pyparsing!=2.0.0,!=2.0.4,>=1.5.6 (from matplotlib)
  Downloading pyparsing-2.1.1-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil->matplotlib)
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, pytz, cycler, pyparsing, matplotlib
  Running setup.py install for matplotlib ... done
Successfully installed cycler-0.10.0 matplotlib-1.5.1 pyparsing-2.1.1 python-dateutil-2.5.2 pytz-2016.3 six-1.10.0
[root@localhost perrin]# 

在安装好matplotlib的同时自动安装了一些所依赖的python相关包,比如cycler-0.10.0、pyparsing-2.1.1、python-dateutil-2.5.2、pytz-2016.3、six-1.10.0。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值