我遇到了同样的问题,最后通过检查编译命令找到了解决方案。真的很简单:
ln -s /usr/local/opt/freetype/include/freetype2 /usr/local/include/freetype解决方法
我已经matplotlib-1.2.1安装了以及numpy-1.8.0。注意-我正在使用安装了自制软件的系统python-我已经进行了$PYTHONPATH设置,以便Python从/Library/Python/x.y/site-packages(pip安装位置)加载。
这是安装代码matplotlib(配置)
BUILDING MATPLOTLIB matplotlib: yes [1.3.1]python: yes [2.7.5 (default,Aug 25 2013,00:04:04) [GCC4.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 theWebAgg backend. pip/easy_install may attempt toinstall it after matplotlib.] pyparsing: yes [pyparsing was not found. It is required formathtext support. pip/easy_install may attempt toinstall it after matplotlib.] pycxx: yes [Couldn’t import. Using local copy.]libagg: yes [pkg-config information for ’libagg’ could notbe 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 thematplotlib test suite]OPTIONAL BACKEND EXTENSIONSmacosx: 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 DEPENDENCIESdvipng: yes [version 1.14] ghostscript: yes [version 9.02] latex: yes [version 3.1415926] pdftops: no
然后,在复制和构建文件之后,build_ext由于缺少头文件,它到达并失败。
running build_extbuilding ’matplotlib.ft2font’ extensioncreating build/temp.macosx-10.9-intel-2.7creating build/temp.macosx-10.9-intel-2.7/srccreating build/temp.macosx-10.9-intel-2.7/CXXcc -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.oclang: 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 ) ~ ^~~~ 0In 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-infoCleaning 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(’rn’,’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/matplotlibException 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,*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(’rn’,’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