CentOS 7 matplotlibのインストール

12401 ワード

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をインストールすると、cycler-0.10.0、pyparsing-2.1.1、python-dateutil-2.5.2、pytz-2016.3、six-1.10.0など、依存するpython関連パッケージが自動的にインストールされます.