2012-05-09 138 views
4

我一直在安裝matplotlib時遇到問題。我遇到了許多其他主題的類似錯誤,但這些解決方案都沒有爲我工作。我已經嘗試通過pip和git安裝matplotlib,並且每次我都非常感謝幫助時收到相同的錯誤。Python - 在Mac OSX中安裝matplotlib Snow Leopard

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

看起來像是遇到了'freetype2'的問題。有兩種方法是安裝[homebrew](http://mxcl.github.com/homebrew/)並以這種方式安裝'python',然後執行'brew install freetype'並使用該python安裝matplotlib。另一種方法是安裝[Quartz X11](http://xquartz.macosforge.org/trac/wiki),它會給你更多更新和更新的freetype庫。 – birryree

+0

儘管你可以使用像MacPorts或homebrew這樣的包管理器來在OS X上安裝matplotlib,但是如果你對僅使用XCode提供的freetype和libpng庫的方法感興趣,請參閱我對相關問題的回答[here](http ://stackoverflow.com/a/10843478/781673)。 – mhowison

回答

1

您可以輕鬆地與homebrew DOIT:

$ 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 
+0

如果我運行python setup.py生成或python setup.py安裝它給上述信息仍然 – tilteddriveway

4

我會強烈建議要經過的軟件包管理器,而不是試圖通過自己編寫的源代碼。這樣更有效率。

一個不錯的選擇,自制是著名MacPorts包管理器:

sudo port install py27-matplotlib 

我用Fink,爲OS X的第三大包管理器,在過去,我發現MacPorts的顯著更強大,向上至今。

Web上的OS X軟件包管理器(包括某些nice ones)之間有許多比較,以便您可以更好地決定要提交哪個管理器。

7

我有同樣的問題。我用啤酒。我做

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

默認情況下修正了這個,釀造離開的FreeType和libpng活躍,這就是爲什麼你需要做的「釀造鏈接」,以及你的系統版本。希望有所幫助。

更新:我現在推薦使用免費版本的Anaconda Python。那麼這是微不足道的。

+0

看起來像新版本的自制程序需要使用'--force'進行鏈接,即'brew link --force freetype'等。除此之外,這些步驟完美運作,謝謝! – alexandroid

相關問題