我在安装matplotlib时遇到了麻烦。我在许多其他主题上遇到了类似的错误,但这些解决方案都没有为我工作。我尝试通过pip和git安装matplotlib,每次我非常感谢帮助时都会收到同样的错误。
In file included from src/ft2font.cpp:3:
src/ft2font.h:16:22: error: ft2build.h: No such file or directory
src/ft2font.h:17:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:18:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:19:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:20:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:21:10: error: #include expects "FILENAME" or <FILENAME>
In file included from src/ft2font.cpp:3:
src/ft2font.h:34: error: 'FT_Bitmap' has not been declared
src/ft2font.h:34: error: 'FT_Int' has not been declared
src/ft2font.h:34: error: 'FT_Int' has not been declared
src/ft2font.h:86: error: expected ',' or '...' before '&' token
src/ft2font.h:86: error: ISO C++ forbids declaration of 'FT_Face' with no type
src/ft2font.h:132: error: 'FT_Face' does not name a type
src/ft2font.h:133: error: 'FT_Matrix' does not name a type
src/ft2font.h:134: error: 'FT_Vector' does not name a type
src/ft2font.h:135: error: 'FT_Error' does not name a type
src/ft2font.h:136: error: 'FT_Glyph' was not declared in this scope
src/ft2font.h:136: error: template argument 1 is invalid
src/ft2font.h:136: error: template argument 2 is invalid
src/ft2font.h:137: error: 'FT_Vector' was not declared in this scope
src/ft2font.h:137: error: template argument 1 is invalid
src/ft2font.h:137: error: template argument 2 is invalid
src/ft2font.h:143: error: 'FT_BBox' does not name a type
src/ft2font.cpp:41: error: 'FT_Library' does not name a type
src/ft2font.cpp:106: error: variable or field 'draw_bitmap' declared void
src/ft2font.cpp:106: error: 'FT_Bitmap' was not declared in this scope
src/ft2font.cpp:106: error: 'bitmap' was not declared in this scope
src/ft2font.cpp:107: error: 'FT_Int' was not declared in this scope
src/ft2font.cpp:108: error: 'FT_Int' was not declared in this scope
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1532: warning: 'int _import_array()' defined but not used
error: command '/usr/bin/gcc-4.2' failed with exit status 1
答案 0 :(得分:7)
我遇到了同样的问题。我用brew。我通过做
来解决这个问题brew install freetype
brew link freetype
brew install libpng
brew link libpng
brew install matplotlib
默认情况下,brew会使您的系统版本的freetype和libpng处于活动状态,这也是您需要执行“brew链接”的原因。希望有所帮助。
更新:我现在建议使用免费版的Anaconda Python。然后这是微不足道的。
答案 1 :(得分:4)
我强烈建议您通过包管理器而不是自己编译源代码。这样效率更高。
自制软件的另一个不错的选择是着名的MacPorts软件包管理器:
sudo port install py27-matplotlib
过去,我使用了OS {X的第三个主要包管理器Fink,我发现MacPorts更加强大和最新。
Web上的OS X包管理器之间存在许多比较(包括一些nice ones),因此您可以更好地决定要提交哪个管理器。
答案 2 :(得分:1)
您可以使用homebrew轻松完成:
$ brew install python
$ brew install gfortran
$ brew install pkg-config
$ easy_install pip
$ pip install numpy
$ cd $HOME
$ git clone https://github.com/matplotlib/matplotlib.git
$ cd matplotlib
$ python setup.py build
$ python setup.py install