“The _imaging C module is notinstalled”
Also see the PIL FAQ.
Why does PIL say “The _imaging C module is not installed”?
The PIL library consists of two main parts: a number of Python modules, usually stored in a PIL subdirectory, and a binary extension module called _imaging. Depending on platform and version, the latter is stored in a file named _imaging.pyd, _imaging.dll or _imaging.so (or some variation thereof).
If Python fails to import the _imaging module, some parts of PIL still works. You can for example import most modules, and open and identify most image files. However, if you invoke a method that needs functions provided by the extension module, PIL raises an ImportError.
Things to check:
Do you have an _imaging module?
On Windows, look for a file called _imaging.pyd or (less common) _imaging.dll. On Unix, look for a file called _imaging.so or _imagingmodule.so. Some Unix platforms may use other extensions (e.g. .sl).
Can Python find the _imaging module?
As for all other Python modules, Python searches the Python module path when looking for the _imaging module. If the module cannot be found on the path, Python will not load it.
To check what Python is doing, run the interpreter with the -v option, and import the Image module:
$python-v...
>>>importImage#C:\py21\PIL\Image.pycmatchesC:\py21\PIL\Image.py
importImage#precompiledfromC:\py21\PIL\Image.pyc
...
import_imaging#dynamicallyloadedfromC:\py21\PIL\_imaging.pyd
...
Another way to check the path is to print the sys.path variable (it’s a Python list) and make sure it contains the right directories:
importsys
printsys.path
You can either type the commands into a Python command line, or put them in a text file and run it as a Python script.
For information on how to modify the path on your platform, see your favourite Python tutorial. If nothing else helps, you can simply modify the sys.path variable in your program.
Can Python load the _imaging module?
If everything looks fine this far, the problem might be that the module found by Python isn’t compatible with the Python interpreter. This problem is most common on Windows, where extensions built for a given minor version of Python (e.g. 2.1) only works with that version, or revisions thereof (e.g. 2.1.2, but not 2.2).
To check if this is the problem, start the interpreter, and import the _imaging module directly:
$python...
>>>import_imaging
If the module is not compatible, earlier versions of Python usually says something like “Unable to locate DLL” (referring to the Python interpreter DLL). Python 2.2 and later usually says “Module use of pythonXX.dll conflicts with this version of Python.”
If you get “undefined symbol: ImagingRadianceEncode” on Mandrake Linux, you have a broken PIL build. You can either build PIL from the PythonWare sources, or make sure you have the latest version of the appropriate Mandrake package.