简体   繁体   English

Python - 在Mac OSX Snow Leopard中安装matplotlib

[英]Python - Installing matplotlib in Mac OSX Snow Leopard

I've been having trouble installing matplotlib. 我在安装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. 我已经尝试通过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

I had the same problem. 我有同样的问题。 I use brew. 我用brew。 I fixed this by doing 我这样做了

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

By default, brew leaves your system versions of freetype and libpng active, which is why you need to do "brew link" as well. 默认情况下,brew会使您的系统版本的freetype和libpng处于活动状态,这也是您需要执行“brew链接”的原因。 Hope that helps. 希望有所帮助。

Update: I would now recommend using the free version of Anaconda Python. 更新:我现在建议使用免费版的Anaconda Python。 Then this is trivial. 然后这是微不足道的。

I would strongly recommend to go through a package manager instead of trying to compile source code by yourself. 我强烈建议您通过一个包管理器而不是尝试自己编译源代码。 This is much more efficient. 这样效率更高。

An nice alternative to homebrew is the famous MacPorts package manager: 自制软件的一个不错的选择是着名的MacPorts包管理器:

sudo port install py27-matplotlib

I used Fink , the third major package manager for OS X, in the past, and I find MacPorts significantly more robust and up-to-date. 我过去使用了OS X的第三个主要包管理器Fink ,我发现MacPorts更加强大和最新。

There are many comparisons between the OS X package managers on the web (including some nice ones ), so that you can better decide which manager to commit to. Web上的OS X包管理器之间有许多比较(包括一些不错的 ),这样您就可以更好地决定要提交哪个管理器。

You can doit in easy way with 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM