歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> CentOS7安裝matplotlib

CentOS7安裝matplotlib

日期:2017/3/6 9:42:34   编辑:學習Linux

CentOS7安裝matplotlib


CentOS7安裝matplotlib


PROBLEM

CentOS 7下 安裝matplotlib。

pip install matplotlib

報錯如下:

[root@localhost Desktop]# pip install matplotlibCollecting 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-develsudo yum install libpng-develsudo pip install matplotlib

RESULT

[root@localhost perrin]# pip install matplotlibCollecting matplotlib  Using cached matplotlib-1.5.1.tar.gzRequirement 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.whlCollecting pyparsing!=2.0.0,!=2.0.4,>=1.5.6 (from matplotlib)  Downloading pyparsing-2.1.1-py2.py3-none-any.whlCollecting six>=1.5 (from python-dateutil->matplotlib)  Downloading six-1.10.0-py2.py3-none-any.whlInstalling collected packages: six, python-dateutil, pytz, cycler, pyparsing, matplotlib  Running setup.py install for matplotlib ... doneSuccessfully 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。

http://xxxxxx/Linuxjc/1134377.html TechArticle

Copyright © Linux教程網 All Rights Reserved