かぴぶろぐ

またかぴったかと思った・・・(´A`;)

python のImage処理ライブラリPILのインストールでハマったのでメモ。

カテゴリ[ Python ]

M氏から情報頂きました<(_ _)>

 

easy_install PIL

普通は、これでOKなのだが、、、

Searching for PIL
Reading http://cheeseshop.python.org/pypi/PIL/
Reading http://www.pythonware.com/products/pil
Reading http://effbot.org/downloads/#Imaging
Reading http://cheeseshop.python.org/pypi/PIL/1.1.6
No local packages or download links found for PIL
error: Could not find suitable distribution for Requirement.parse('PIL')

。。。なぜか見つからない。

普通に、cheeseshopのトップから検索すると、、、

http://pypi.python.org/pypi/PIL/1.1.6

。。。ある。

ググってみると、同様にハマった先人が居たので、

http://www.martin-geber.com/thought/2007/08/22/problems-installing-easy_install-pil/

これを参考に、

sudo easy_install --find-links http://www.pythonware.com/products/pil/ Imaging

で、インストール成功!
。。。と言いたい所だが、Mac使いには世の中そんなに甘く無い。
俺のIntel-Macの開発環境では、さらに

gcc -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.4/_imagingtk.o build/temp.macosx-10.3-fat-2.4/Tk/tkImaging.o -L/sw/lib -L/opt/local/lib -L/usr/local/lib -L/Library/Frameworks/Python.framework/Versions/2.4/lib -L/usr/lib -o build/lib.macosx-10.3-fat-2.4/_imagingtk.so -framework Tcl -framework Tk ld: in /sw/lib/libxml2.2.dylib, file is not of required architecture for architecture ppc
collect2: ld returned 1 exit status
 lipo: can't open input file: /var/folders/ha/hafnBYAMG1SYxzu3hSAwOk+++TI/-Tmp-//ccqW04h5.out (No such file or directory)
 error: command 'gcc' failed with exit status 1

とか言う、コンパイル時にエラーが出る。
エラーを見ると、fatバイナリ(Intel/PowerPC共通バイナリ)を生成するように、コンパイラに指示している模様。
。。。余計な事を。。。

潔く、cheeseshop経由をあきらめて、本家(http://www.pythonware.com/products/pil/)から、ソースのtarballを取ってくる。

取ってきたtarballを展開して、手動でビルド。

python setup.py build

もちろん、さっきと同様にコケる。

もしかすると、setup.pyのオプションでどうにか出来たりするのかもしれないが、今回は、さっさとイントール終わらせたいので、強引に解決する事にする。

最後のリンクでコケてるダケなので、-archオプションのppcの指定をカットしてgccを一発実行させれば良いハズ。

gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.4/_imagingtk.o build/temp.macosx-10.3-fat-2.4/Tk/tkImaging.o -L/sw/lib -L/opt/local/lib -L/usr/local/lib -L/Library/Frameworks/Python.framework/Versions/2.4/lib -L/usr/lib -o build/lib.macosx-10.3-fat-2.4/_imagingtk.so -framework Tcl -framework Tk

はい、期待通りにリンクが成功。

ライブラリが作成されてるので、インストールを実行。

python setup.py install

で、インストール完了。。。。しない。

パーミッションが無いって怒られたので、sudo付きで。。。

sudo python setup.py install

今度こそ、インストール完了。
乙。

 

http://kapi.jp/kapi_blog/246

2009年07月10日

関連カテゴリ Python

この記事のコメント

この記事にコメントする