2012年11月1日木曜日

[python]macへ PIL FREETYPE2 support available でのインストール

sphinx の block-diag や seq-diag を使う際にフォントをTrueTypeフォントで設定。

make html すると以下エラー。


ImportError: The _imagingft C module is not installed

この原因と対応方法はこちらの6以降参照。

ざっくりそのまま転載するとPILの
後日ためしたところ上手く行ったが、FREETYPE2 support not available となってしまっている。

が原因。

こういう感じ。

    --------------------------------------------------------------------

    PIL 1.1.7 SETUP SUMMARY

    --------------------------------------------------------------------

    version       1.1.7

    platform      darwin 2.7.2 (default, Nov  9 2011, 19:35:03)

                  [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)]

    --------------------------------------------------------------------

    --- TKINTER support available

    --- JPEG support available

    --- ZLIB (PNG/ZIP) support available

    *** FREETYPE2 support not available

    --- LITTLECMS support available

    --------------------------------------------------------------------

    To add a missing option, make sure you have the required

    library, and set the corresponding ROOT variable in the

    setup.py script.

で、これをなおすにはこれを参考にしつつ次。
$ pip uninstall PIL

$ ln -s /usr/X11/include/freetype2 /usr/local/include/

$ ln -s /usr/X11/include/ft2build.h /usr/local/include/

$ ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/

$ ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/libfreetype.dylib

$ pip install PIL

で、これでいいんだけれど、私の mac mountail lion pre install な PC だと
/usr/X11/include/freetype2 もなければ、/usr/local/include/ もない。
※ないのはX11入れてないからかな?X11いれずにXCodeいれた山ライオンだとこうなるのかもね。

探してみると

※sudo find / -name freetype2 とかね

ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include/freetype2 /usr/local/include/

ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include/ft2build.h /usr/local/include/

ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/lib/libfreetype.6.dylib /usr/local/lib/

ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/lib/libfreetype.6.dylib /usr/local/lib/libfreetype.dylib


となった。

多分、XCodeのコマンドラインツールをインストールしてないとダメっぽいね。

予め gcc とか make するためにXCode のコマンドラインツールはインストールしてた。

これで sudo pip install pil したら

    --------------------------------------------------------------------

    PIL 1.1.7 SETUP SUMMARY

    --------------------------------------------------------------------

    version       1.1.7

    platform      darwin 2.7.2 (default, Jun 20 2012, 16:23:33)

                  [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]

    --------------------------------------------------------------------

    --- TKINTER support available

    *** JPEG support not available

    --- ZLIB (PNG/ZIP) support available

    --- FREETYPE2 support available

    *** LITTLECMS support not available

    --------------------------------------------------------------------

無事こうなりました。

おわり。

0 件のコメント:

コメントを投稿