我正试图安装matplotlib,以便在MacOSX上用Python绘制应用程序。当我运行“Python setup.py install”时,它会给我带来大量错误:http://pastebin.com/u7fL37ic。
一个简短的片段:
src/ft2font.cpp:2170: error: ‘FT_LOAD_TARGET_MONO’ was not declared in this scope
src/ft2font.cpp:2171: error: ‘FT_LOAD_TARGET_LCD’ was not declared in this scope
src/ft2font.cpp:2172: error: ‘FT_LOAD_TARGET_LCD_V’ was not declared in this scope
src/ft2font.cpp:2175: error: ‘_ft2Library’ was not declared in this scope
src/ft2font.cpp:2175: error: ‘FT_Init_FreeType’ was not declared in this scope
src/ft2font.cpp: In destructor ‘virtual ft2font_module::~ft2font_module()’:
src/ft2font.cpp:2186: error: ‘_ft2Library’ was not declared in this scope
src/ft2font.cpp:2186: error: ‘FT_Done_FreeType’ was not declared in this scope
lipo: can't figure out the architecture type of: /var/folders/Nj/Njnlp9qSF64sMESWcaDnk++++TI/-Tmp-//cchyYmM5.out
error: command 'gcc-4.0' failed with exit status 1
我使用MacPorts安装了freetype,我认为这可以解决问题,但没有运气。给了我和以前一样的错误。似乎找不到正确的freetype文件:
BUILDING MATPLOTLIB
matplotlib: 1.0.0
python: 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) [GCC
4.0.1 (Apple Inc. build 5493)]
platform: darwin
REQUIRED DEPENDENCIES
numpy: 1.5.0
freetype2: found, but unknown version (no pkg-config)
* WARNING: Could not find 'freetype2' headers in any
* of '.', './freetype2'.
我应该把freetype文件放在哪里才能找到它们?现在它们在/opt/local/lib中
有什么想法吗?
你也可以考虑使用热情分配(即使是非商业用途的免费分配) 它完全安装起来没有任何困难 http://www.enthought.com/products/getepd.php (我与热情没有任何关系-我只是一个满意的用户)
老了,但当我在雪豹身上遇到同样的问题时,我的搜索仍然突然出现。
你说你在用自制的,所以你需要
安装后(使用“brew install freetype”)。
这就克服了那个错误。我对libpng也做了同样的事情,结果安装成功。
问题的根源在于,freetype和libpng是由XCode安装在非规范位置的/usr/X11,而不是/usr或/usr/local。
所有已经给出的答案都通过重新构建freetype和libpng来解决这个问题,无论是手动还是使用像homebrew这样的包管理器。
但是,只需将现有的freetype/libpng头文件和库符号链接到/usr/local树中,就可以编译matplotlib:
我更喜欢用pip构建python包,因此我将使用:
如果您还没有pip,可以使用easy_install(随OS X提供)安装它:
我只在10.7版(Lion)上测试过这个,但我怀疑它也能在10.6版上运行。
这是一个小技巧,但我发现这是针对OSX附带的stock python框架安装matplotlib的最简单方法。10.7中的stock python框架实际上相当不错,包括一个链接到苹果优化的BLAS库(Accelerate)的numpy-1.5.1包:
相关问题 更多 >
编程相关推荐