Como instalar o Matplotlib no Ubuntu 14.04?

1

Motivação em 14.04: 16.04 é um buggy para uso em produção. 14.04 é o único estável. 15.10 também é buggy. Sua upstart / systemd com runit é horrível.

Eu corro masi@masi:~/BitTorrentSync/IPython$ sudo -H pip install matplotlib

Collecting matplotlib
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading matplotlib-1.5.1.tar.gz (54.0MB)
    100% |████████████████████████████████| 54.0MB 26kB/s 
    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 [2.7.6 (default, Jun 22 2015, 17:58:13)  [GCC
                            4.8.2]]
                  platform: yes [linux2]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.11.0]
                  dateutil: yes [using dateutil version 2.5.3]
                      pytz: yes [using pytz version 2016.4]
                    cycler: yes [cycler was not found. pip will attempt to
                            install it after matplotlib.]
                   tornado: yes [using tornado version 4.3]
                 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 / mock is
                            required to run the matplotlib test suite. Please
                            install it with pip or your preferred tool to run
                            the test suite]
            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 / mock is
                            required to run the matplotlib test suite. Please
                            install it with pip or your preferred tool to run
                            the test suite]

    OPTIONAL BACKEND EXTENSIONS
                    macosx: no  [Mac OS-X only]
                    qt5agg: no  [PyQt5 not found]
                    qt4agg: yes [installing, Qt: 4.8.6, PyQt: 4.8.6; PySide not
                            found]
                   gtk3agg: yes [installing, version 3.8.10]
                 gtk3cairo: yes [installing, version 3.8.10]
                    gtkagg: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                            be found.  You may need to install the development
                            package.]
                     tkagg: no  [TKAgg requires Tkinter.]
                     wxagg: no  [requires wxPython]
                       gtk: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                            be found.  You may need to install the development
                            package.]
                       agg: yes [installing]
                     cairo: yes [installing, pycairo version 1.8.8]
                 windowing: no  [Microsoft Windows only]

    OPTIONAL LATEX DEPENDENCIES
                    dvipng: no
               ghostscript: yes [version 9.10]
                     latex: no
                   pdftops: yes [version 0.24.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-5VdgT2/matplotlib/

onde código de erro 1 não retornou nenhum encadeamento correspondente. Eu tenho exatamente o mesmo erro ao executar o comando sem sudo -H . Esta é uma instalação incompleta, tentando usar o módulo que você obtém

ImportError: No module named matplotlib.pyplot

Proposta em comentário. Eu corro sudo apt-get install libfreetype6-dev libpng12-dev com sucesso. Eu corro com sucesso sudo -H pip install matplotlib . No entanto, recebo o aviso ao executar o módulo matplotlib agora

/usr/local/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')

Como você pode instalar o matplotlib no Ubuntu 14.04?

    
por Léo Léopold Hertz 준영 29.05.2016 / 10:34

1 resposta

0

Comentário de Edwinksl e discussão . O último aviso é o aviso de cache da fonte. Inicie ipython para descobrir o diretório de cache do Matplotlib

In [2]: import matplotlib
In [3]: matplotlib.get_cachedir()
Out[3]: u'/home/masi/.cache/matplotlib'

No meu caso, exclua

rm /home/masi/.cache/matplotlib/fontList.cache 
rm -r /home/masi/.cache/matplotlib/tex.cache/

Agora, execute seu código de teste do matplotlib novamente. Eu recebi o mesmo erro novamente com a primeira execução. Eu corro o código de teste na segunda vez e o caso foi resolvido. A proposta de Edwinksl porque tem o comportamento

% bl0ck_qu0te%     
por Léo Léopold Hertz 준영 23.05.2017 / 14:39