4

I've been having trouble installing matplotlib. I'm getting a similar error to many other topics, but none of those solutions have been working for me. I have tried installing matplotlib via pip and via git and I receive the same error every time I would very much appreciate help.

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
4

3 回答 3

7

我有同样的问题。我用酿造。我通过这样做解决了这个问题

brew install freetype
brew link freetype
brew install libpng
brew link libpng
brew install matplotlib

默认情况下,brew 使您的系统版本的 freetype 和 libpng 处于活动状态,这也是您需要执行“brew link”的原因。希望有帮助。

更新:我现在建议使用 Anaconda Python 的免费版本。那么这是微不足道的。

于 2012-10-06T12:11:01.573 回答
4

我强烈建议通过包管理器而不是尝试自己编译源代码。这效率更高。

一个不错的替代自制软件是著名的MacPorts包管理器:

sudo port install py27-matplotlib

过去,我使用过Fink,它是 OS X 的第三个主要包管理器,我发现 MacPorts 更加强大和最新。

网上有很多 OS X 包管理器之间的比较(包括一些不错的),以便您更好地决定要提交哪个管理器。

于 2012-05-09T07:08:56.550 回答
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
于 2012-05-09T00:53:44.807 回答