web-dev-qa-db-fra.com

`Sudo pip install matplotlib` ne trouve pas les en-têtes freetype. [OS X Mavericks / 10.9]

J'ai déjà matplotlib-1.2.1 installé ainsi que numpy-1.8.0. Remarque - J'utilise le système python avec homebrew installé - j'ai $PYTHONPATH set so Python se charge depuis /Library/Python/x.y/site-packages (où pip s'installe).

Voici le code pour installer matplotlib (les configurations)

BUILDING MATPLOTLIB
            matplotlib: yes [1.3.1]
                python: yes [2.7.5 (default, Aug 25 2013, 00:04:04)  [GCC
                        4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]]
              platform: yes [darwin]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.8.0]
              dateutil: yes [using dateutil version 1.5]
               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.]
                 pycxx: yes [Couldn't import.  Using local copy.]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: yes [version 17.1.11]
                   png: yes [version 1.5.17]

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]

OPTIONAL BACKEND EXTENSIONS
                macosx: yes [installing, darwin]
                qt4agg: no  [PyQt4 not found]
               gtk3agg: no  [Requires pygobject to be installed.]
             gtk3cairo: no  [Requires cairo to be installed.]
                gtkagg: no  [Requires pygtk]
                 tkagg: yes [installing, version 81008]
                 wxagg: no  [requires wxPython]
                   gtk: no  [Requires pygtk]
                   agg: yes [installing]
                 cairo: no  [cairo not found]
             windowing: no  [Microsoft Windows only]

OPTIONAL LATEX DEPENDENCIES
                dvipng: yes [version 1.14]
           ghostscript: yes [version 9.02]
                 latex: yes [version 3.1415926]
               pdftops: no

Et plus tard, après avoir copié et créé des fichiers, il arrive à build_ext et échoue en raison de fichiers d'en-tête manquants.

running build_ext
building 'matplotlib.ft2font' extension
creating build/temp.macosx-10.9-intel-2.7
creating build/temp.macosx-10.9-intel-2.7/src
creating build/temp.macosx-10.9-intel-2.7/CXX
cc -fno-strict-aliasing -fno-common -dynamic -Arch x86_64 -Arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -Arch x86_64 -Arch i386 -pipe -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I/usr/local/include -I/usr/include -I/usr/X11/include -I. -I/usr/local/Cellar/freetype/2.5.2/include/freetype2 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/ft2font.cpp -o build/temp.macosx-10.9-intel-2.7/src/ft2font.o

clang: warning: argument unused during compilation: '-mno-fused-madd'
In file included from src/ft2font.cpp:3:
In file included from src/ft2font.h:6:
In file included from ./CXX/Extensions.hxx:40:
In file included from ./CXX/Python2/Extensions.hxx:52:
./CXX/Python2/Objects.hxx:1133:23: warning: implicit conversion of NULL constant to 'int' [-Wnull-conversion]
            , offset( NULL )
                    ~ ^~~~
                      0

In file included from src/ft2font.cpp:3:
In file included from src/ft2font.h:16:
/usr/X11/include/ft2build.h:56:10: fatal error: 'freetype/config/ftheader.h' file not found
#include <freetype/config/ftheader.h>
         ^
1 warning and 1 error generated.

error: command 'cc' failed with exit status 1
----------------------------------------

  Rolling back uninstall of matplotlib
  Replacing /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib-1.1.1-py2.7.Egg-info
Cleaning up...
  Removing temporary dir /private/tmp/pip_build_root...
Command /usr/bin/python -c "import setuptools;__file__='/private/tmp/pip_build_root/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-vHUPhA-record/install-record.txt --single-version-externally-managed failed with error code 1 in /private/tmp/pip_build_root/matplotlib
Exception information:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.Egg/pip/basecommand.py", line 134, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.Egg/pip/commands/install.py", line 241, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.Egg/pip/req.py", line 1298, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.Egg/pip/req.py", line 625, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.Egg/pip/util.py", line 670, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/bin/python -c "import setuptools;__file__='/private/tmp/pip_build_root/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-vHUPhA-record/install-record.txt --single-version-externally-managed failed with error code 1 in /private/tmp/pip_build_root/matplotlib
46
kratsg

J'ai eu le même problème et j'ai finalement trouvé la solution en vérifiant les commandes de compilation. C'est vraiment simple:

ln -s /usr/local/opt/freetype/include/freetype2 /usr/local/include/freetype
89
Luis M Rodriguez-R