安装matplotlib时出错

2024-04-28 17:44:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经尝试过使用pip install matplotlibgit clone然后python setup.py install,如the installation faq中对Mac OS 10.7的描述。但我也犯了同样的错误:

[...]
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I. -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include/freetype2 -I./freetype2 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/ft2font.cpp -o build/temp.macosx-10.7-intel-2.7/src/ft2font.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
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
[...]

好像我的系统里少了一些软件包?或者还有其他更好的安装matplotlib的方法吗?

谢谢!

更新:通过google和搜索,我发现我可能缺少freetype2软件包,但是,如果我尝试通过自制程序安装它,我会收到一条警告消息:

[me @ my mac]$ brew search freetype
Apple distributes freetype with OS X, you can find it in /usr/X11/lib.
However not all build scripts look here, so you may need to call ENV.x11
in your formula's install function.

Tags: installorsrcincludelibrarynotframeworkerror
3条回答

同样的错误,安装在我的一台Lion机器上,而不是另一台。找到一个丢失的pkg配置

$ brew install pkg-config
$ pip install -U 'http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz/download'

(另见https://jholewinski.org/blog/installing-matplotlib-on-os-x-10-7-with-homebrew/

谢谢上面的链接。我可以让matplotlib做一些小改动。我正在记录我遇到的特定错误消息,以备将来参考。

环境: MacOSX10.7.4(Lion)运行股票Python2.7.1(见/usr/bin)

我开始尝试让matplotlib在默认安装下工作。setup.py特别指出了一些问题:

freetype2: found, but unknown version (no pkg-config)
                        * WARNING: Could not find 'freetype2' headers in any
                        * of '.', './freetype2'.

以及

OPTIONAL BACKEND DEPENDENCIES
                libpng: found, but unknown version (no pkg-config)
                        * Could not find 'libpng' headers in any of '.'

安装步骤将失败,并显示以下错误消息:

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include/numpy/__multiarray_api.h:1187: warning: ‘int _import_array()’ defined but not used
lipo: can't open input file: /var/tmp//ccG28dDI.out (No such file or directory)

搜索这个文件没有任何帮助。我仔细研究了一下,认为我不值得花时间沿着virtualenv路线走下去。

我最终遵循了上面jholewinski链接中概述的步骤。在/usr/local/中安装了一个新的Python2.7.4,并按照那里的说明操作。(我重新安装了pkg config)。 我可以从git中提取最新版本的matplotlib,它运行得很好。

libpng(1.5.4)和freetype2(13.2.7)库这次都出现了。

我在Ubuntu服务器12.04上遇到了这个问题。

我必须从存储库中安装libfreetype6-devlibpng-dev。当我遇到这个问题时,我正在使用virtualenv并使用pip安装matplotlib。

我需要这样做的提示来自matplotlib安装早期弹出的警告消息,因此请注意那些指示找到依赖项的消息,而不是标题。

相关问题 更多 >