python - 安装 matplotlib 时出错 - python2.7 (RHEL 5.9)

标签 python linux redhat

我的 RHEL 5.9 桌面上有 python 2.7 的替代安装(python 2.4 随 rhel5 一起提供)。我已经从源代码成功安装了 numpy1.7.1scipy-0.12.0。但是,当我尝试构建 matplotlib1.2.1 (python2.7 setup.py build) 时,我收到以下无法调试的错误消息

============================================================================
BUILDING MATPLOTLIB
            matplotlib: 1.2.1
                python: 2.7.5 (default, May 16 2013, 15:45:29)  [GCC 4.1.2
                        20080704 (Red Hat 4.1.2-54)]
              platform: linux2

REQUIRED DEPENDENCIES
                 numpy: 1.7.1
             freetype2: found, but unknown version (no pkg-config)
                        * WARNING: Could not find 'freetype2' headers in any
                        * of '/usr/local/include', '/usr/include',
                        * '/usr/local/include', '/usr/include', '.',
                        * '/usr/local/include/freetype2',
                        * '/usr/include/freetype2',
                        * '/usr/local/include/freetype2',
                        * '/usr/include/freetype2', './freetype2'.

OPTIONAL BACKEND DEPENDENCIES
                libpng: found, but unknown version (no pkg-config)
                        * Could not find 'libpng' headers in any of
                        * '/usr/local/include', '/usr/include',
                        * '/usr/local/include', '/usr/include', '.'
               Tkinter: Tkinter: 81008, Tk: 8.4, Tcl: 8.4
                  Gtk+: no
                        * Building for Gtk+ requires pygtk; you must be able
                        * to "import gtk" in your build/install environment
       Mac OS X native: no
                    Qt: no
                   Qt4: no
                PySide: no
                 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
              dateutil: matplotlib will provide
                  pytz: matplotlib will provide

OPTIONAL USETEX DEPENDENCIES
                dvipng: 1.5
           ghostscript: 8.70
                 latex: 3.141592
               pdftops: 3.00

[Edit setup.cfg to suppress the above messages]
============================================================================
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz', 'dateutil', 'dateutil.zoneinfo']
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-x86_64-2.7/matplotlib/mpl-data
running build_ext
building 'matplotlib.ft2font' extension
gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wall -g -O -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/include -I/usr/include -I/usr/local/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include -I/usr/include -I. -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I/usr/local/lib/python2.7/site-packages/numpy/core/include/freetype2 -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I./freetype2 -I/usr/local/include/python2.7 -c src/ft2font.cpp -o build/temp.linux-x86_64-2.7/src/ft2font.o
In file included from src/ft2font.cpp:3:
src/ft2font.h:16:22: error: ft2build.h: No such file or directory
src/ft2font.h:17:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:18:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:19:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:20:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:21:10: error: #include expects "FILENAME" or <FILENAME>
In file included from /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1728,
                 from /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
                 from /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:15,
                 from src/ft2font.cpp:7:
/usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
src/ft2font.h:34: error: ‘FT_Bitmap’ has not been declared
src/ft2font.h:34: error: ‘FT_Int’ has not been declared
src/ft2font.h:34: error: ‘FT_Int’ has not been declared
src/ft2font.h:86: error: expected ‘,’ or ‘...’ before ‘&’ token
src/ft2font.h:86: error: ISO C++ forbids declaration of ‘FT_Face’ with no type
src/ft2font.h:132: error: ‘FT_Face’ does not name a type
src/ft2font.h:133: error: ‘FT_Matrix’ does not name a type
src/ft2font.h:134: error: ‘FT_Vector’ does not name a type
src/ft2font.h:135: error: ‘FT_Error’ does not name a type
src/ft2font.h:136: error: ‘FT_Glyph’ was not declared in this scope
src/ft2font.h:136: error: template argument 1 is invalid
src/ft2font.h:136: error: template argument 2 is invalid
src/ft2font.h:137: error: ‘FT_Vector’ was not declared in this scope
src/ft2font.h:137: error: template argument 1 is invalid
src/ft2font.h:137: error: template argument 2 is invalid
src/ft2font.h:143: error: ‘FT_BBox’ does not name a type
src/ft2font.cpp:41: error: ‘FT_Library’ does not name a type
src/ft2font.cpp:106: error: variable or field ‘draw_bitmap’ declared void
src/ft2font.cpp:106: error: ‘int FT2Image::draw_bitmap’ is not a static member of ‘class FT2Image’
src/ft2font.cpp:106: error: ‘FT_Bitmap’ was not declared in this scope
src/ft2font.cpp:106: error: ‘bitmap’ was not declared in this scope
src/ft2font.cpp:107: error: ‘FT_Int’ was not declared in this scope
src/ft2font.cpp:108: error: ‘FT_Int’ was not declared in this scope
src/ft2font.cpp:108: error: initializer expression list treated as compound expression
src/ft2font.cpp:109: error: expected ‘,’ or ‘;’ before ‘{’ token
/usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1594: warning: ‘int _import_array()’ defined but not used
error: command 'gcc' failed with exit status 1

我在使用 pip-2.7 和 easy_install-2.7 时收到类似的错误消息。有什么想法吗?


按照 Huy Phan 的安装 freetype-devel 的建议,我得到了一个新的错误日志

basedirlist is: ['/usr/local', '/usr']
============================================================================
BUILDING MATPLOTLIB
            matplotlib: 1.2.1
                python: 2.7.5 (default, May 16 2013, 15:45:29)  [GCC 4.1.2
                        20080704 (Red Hat 4.1.2-54)]
              platform: linux2

REQUIRED DEPENDENCIES
                 numpy: 1.7.1
             freetype2: 9.10.3

OPTIONAL BACKEND DEPENDENCIES
                libpng: found, but unknown version (no pkg-config)
                        * Could not find 'libpng' headers in any of
                        * '/usr/local/include', '/usr/include',
                        * '/usr/local/include', '/usr/include', '.'
               Tkinter: Tkinter: 81008, Tk: 8.4, Tcl: 8.4
                  Gtk+: no
                        * Building for Gtk+ requires pygtk; you must be able
                        * to "import gtk" in your build/install environment
       Mac OS X native: no
                    Qt: no
                   Qt4: no
                PySide: no
                 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
              dateutil: matplotlib will provide
                  pytz: matplotlib will provide

OPTIONAL USETEX DEPENDENCIES
                dvipng: 1.5
           ghostscript: 8.70
                 latex: 3.141592
               pdftops: 3.00

[Edit setup.cfg to suppress the above messages]
============================================================================
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz', 'dateutil', 'dateutil.zoneinfo']
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-x86_64-2.7/matplotlib/mpl-data
running build_ext
building 'matplotlib._png' extension
gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wall -g -O -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/include -I/usr/include -I/usr/local/include -I/usr/include -I. -I/usr/local/lib/python2.7/site-packages/numpy/core/include -I. -I/usr/local/include/python2.7 -c src/_png.cpp -o build/temp.linux-x86_64-2.7/src/_png.o
src/_png.cpp:10:20: error: png.h: No such file or directory
In file included from /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1728,
                 from /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
                 from /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:15,
                 from src/_png.cpp:28:
/usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
src/_png.cpp:67: error: variable or field ‘write_png_data’ declared void
src/_png.cpp:67: error: ‘png_structp’ was not declared in this scope
src/_png.cpp:67: error: ‘png_bytep’ was not declared in this scope
src/_png.cpp:67: error: ‘png_size_t’ was not declared in this scope
src/_png.cpp:67: error: initializer expression list treated as compound expression
src/_png.cpp:68: error: expected ‘,’ or ‘;’ before ‘{’ token
/usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1594: warning: ‘int _import_array()’ defined but not used
src/_png.cpp:67: warning: ‘write_png_data’ defined but not used
error: command 'gcc' failed with exit status 1

最佳答案

看起来你的系统没有安装 freetype-devel。 尝试

sudo yum install freetype-devel 

首先。

另外你可能需要安装libpng-devel,

sudo yum install libpng-devel

关于python - 安装 matplotlib 时出错 - python2.7 (RHEL 5.9),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16958780/

相关文章:

python - MongoDB 中 GB 数据的数据摄取

c - 在 Linux 中使用 GetKeyState(VK_CAPITAL) & 1

linux - Openshift 每小时 cron 作业突然停止工作

python - 如何双击直接用python打开自定义文件?

python - 如何从 python 中的嵌套字典中获取特定键及其值?

python - 网页抓取Python

使用 RS232 的 C 程序仅在启动 minicom 时有效

linux - bash 脚本从文件中获取所花费的时间

python - 使用 Tilestache 时未定义全局名称 'mapnik'

php - 我从/var/run/php-fpm/丢失了我的 php-fpm.sock 文件