Error installing matplotlib - python2.7 (RHEL 5.9)
Question: I have an altinstall of python 2.7 on my RHEL 5.9 desktop (python 2.4 ships
with rhel5). I have installed `numpy1.7.1` and `scipy-0.12.0` successfully
from source. However when I try to build `matplotlib1.2.1` (`python2.7
setup.py build`) I get the following error message which I am unable to debug

    
    
    ============================================================================
    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
    

I get similar error messages when using pip-2.7 and easy_install-2.7. Any
ideas?

* * *

Following Huy Phan's suggestion to install freetype-devel I get a new error
log

    
    
    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
    


Answer: Looks like your system doesn't have `freetype-devel` installed. Try

    
    
    sudo yum install freetype-devel 
    

first.

In addition you may need to install `libpng-devel`,

    
    
    sudo yum install libpng-devel
    

