Sudo pip安装matplotlib无法findfreetype头文件。

我已经安装了matplotlib-1.2.1以及numpy-1.8.0 。 注意 – 我正在使用安装了自制软件的系统python – 我有$PYTHONPATH设置,以便从/Library/Python/xy/site-packages (其中pip安装到)加载/Library/Python/xy/site-packages

这里是安装matplotlib的代码(configuration)

 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 

然后,在复制和构build文件之后,它会转到build_ext并由于缺less头文件而失败。

 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 

我有同样的问题,最后通过检查编译命令find解决scheme。 这很简单:

 ln -s /usr/local/opt/freetype/include/freetype2 /usr/local/include/freetype