Python Imaging LibraryのPillowをインストールする

Pythonで画像処理をやってみたくなり、PIL(Python Imaging Library)をインストールしようとネットで調べたら、Pillow に変わっていた。

Python Imaging Library (PIL)を確認すると、PIL 1.1.7が最新で2009年9月が最終更新になっていた。

ちょっと古いんじゃないのかと調べてみると、setuptools に対応するために、Pillow として fork されたようだ。最近にリリースされた Pillow 2.0.0 ではPython 3.2, 3.3にも対応している。

じわじわと Python3 にライブラリー周辺が対応しはじめているようで、そろそろPython3へ移行しても良さそうな感じがしてきたなあ。

インストールする環境

  • Windows 7 Professional 64bit
  • Python 2.7.3 (32bit)

インストール失敗編

pipでインストールしたら error となり、インストールできなかった。

> pip install pillow

   .....

error: Unable to find vcvarsall.bat

Windows環境において pip でインストールするためには、Microsoft Visual Studioが必要となる。

Make sure to build PIL and the external libraries with the same
runtime linking options as was used for the Python interpreter
(usually /MD, under Visual Studio).

Note that most Python distributions for Windows include libraries
compiled for Microsoft Visual Studio. You can get the free Express
edition of Visual Studio from:
http://www.microsoft.com/Express/

インストール成功編

Pillow 2.0.0 : Python Package Indexのページを下へスクロールしていくと、MS Windows installerが見つかる。

Python 2.7 で32bit用である、Pillow-2.0.0.win32-py2.7.exe をダウンロードし、実行したら無事にインストールできた。

Pillow の公式ドキュメント

Python

Posted by skw