ImportError: No module named PIL

234

I use this command in the shell to install PIL:

easy_install PIL

then I run python and type this: import PIL. But I get this error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named PIL

I've never had such problem, what do you think?

This question is tagged with python python-imaging-library easy-install

~ Asked on 2012-01-14 17:24:27

The Best Answer is


150

On some installs of PIL, you must do

import Image

instead of import PIL (PIL is in fact not always imported this way). Since import Image works for you, this means that you have in fact installed PIL.

Having a different name for the library and the Python module is unusual, but this is what was chosen for (some versions of) PIL.

You can get more information about how to use this module from the official tutorial.

PS: In fact, on some installs, import PIL does work, which adds to the confusion. This is confirmed by an example from the documentation, as @JanneKarila found out, and also by some more recent versions of the MacPorts PIL package (1.1.7).

~ Answered on 2012-01-14 17:36:52


326

In shell, run:

pip install Pillow

Attention: PIL is deprecated, and pillow is the successor.

~ Answered on 2014-03-28 20:49:48


Most Viewed Questions: