AWS / PHP / Python ちょいメモ

amazon web service , PHP, Python を使ったときのメモ。日本語でググってもわからなかった事を中心に。

Pillow インストール前にやっておきたいこと

Sphinx で blockdiag + IPAフォントを使った時のTIPS。Ubuntu上で make html を行ったところ、次のエラーがでて図が出力できなかった。

ImportError: The _imagingft C module is not installed

blockdiag_fontpath で、IPAフォントを指定したところエラーが発生するようになった。フォントは入ってる。

$ fc-list | grep IPA
/usr/share/fonts/opentype/ipafont-mincho/ipam.ttf: IPA明朝,IPAMincho:style=Regular
/usr/share/fonts/opentype/ipafont-gothic/ipagp.ttf: IPA Pゴシック,IPAPGothic:style=Regular
/usr/share/fonts/opentype/ipafont-mincho/ipamp.ttf: IPA P明朝,IPAPMincho:style=Regular
/usr/share/fonts/opentype/ipafont-gothic/ipag.ttf: IPAゴシック,IPAGothic:style=Regular
/usr/share/fonts/truetype/fonts-japanese-mincho.ttf: IPA明朝,IPAMincho:style=Regular
/usr/share/fonts/truetype/fonts-japanese-gothic.ttf: IPAゴシック,IPAGothic:style=Regular


ということで、フォントの処理周りが関連と推測。エラーでググったら、次のエントリーを発見。

ああ、なるほど freetype系をハンドルできないPillowなのかも?

$ sudo apt-get install libfreetype6
$ sudo apt-get install libfreetype6-dev

$ sudo pip uninstall Pillow
$ sudo pip install Pillow

これで、IPAフォントを扱えるPillowになりました。


その他

普段 Pythonのパッケージ管理には pip を使っているのですが、依存関係はすべて解決してくれるという妄想に取り憑かれていたことに気づけました。

必要なものは、事前に揃えねばですね。pipで入ったパッケージも、ちゃんとmakeのログとかみるといいのかも?いままで見たことなかったなぁ。