红联Linux门户
Linux帮助

CentOS 7安装matplotlib

发布时间:2016-06-05 10:01:07来源:blog.csdn.net/junbujianwpl/作者:WarmSword

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)  [GCC4.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。


本文永久更新地址:http://www.linuxdiyf.com/linux/21248.html