web-dev-qa-db-ja.com

matplotlibのインストール中のエラー

Mac OS 10.7の インストールに関するよくある質問 の説明に従って、pip install matplotlibgit clone、次にpython setup.py installを使用してみました。しかし、私は同じエラーを受け取ります:

[...]
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をインストールする他のより良い方法はありますか?

ありがとう!

更新:グーグル検索してSOを検索すると、パッケージfreetype2がない可能性があることがわかりましたが、homebrewでインストールしようとすると、警告メッセージが表示されます。

[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.
36
clwen

Ubuntuサーバー12.04でこの問題が発生しました。

私はインストールする必要がありましたlibfreetype6-devおよびlibpng-devリポジトリから。この問題が発生したとき、私はvirtualenvを使用していて、pipを使用してmatplotlibをインストールしていました。

私がこれを行う必要があるというヒントは、matplotlibインストールの初期にポップアップする警告メッセージから来たので、依存関係が検出されたがヘッダーは検出されなかったことを示すメッセージに注意してください。

80
Javier Rosa

同じエラーで、インストールは私のLionマシンの1つで機能しましたが、他では機能しませんでした。不足しているpkg-configまで追跡しました

$ 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/

13
jon

上記のリンクをありがとう。 matplotlibをいくつかの小さな変更で動作させることができました。今後参照するために、私が遭遇した特定のエラーメッセージを文書化しています。

環境:Mac OS X 10.7.4(Lion)実行中のストックpython 2.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リンクで説明されている手順を実行しました。新しいpython 2.7.4を/ usr/local /にインストールし、そこでの指示に従いました(pkg-configを再インストールしました)。gitから最新バージョンのmatplotlibをプルすることができました。そしてそれはうまくいきました。

今回はlibpng(1.5.4)とfreetype2(13.2.7)の両方のライブラリーが存在しました。

2
Amar