The _imaging C module is not installed

"The _imaging C module is not installed"

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...
>>> import Image# C:\py21\PIL\Image.pyc matches C:\py21\PIL\Image.py
import Image # precompiled from C:\py21\PIL\Image.pyc
...
import _imaging # dynamically loaded from C:\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:

import sys
print sys.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.


转载于:https://my.oschina.net/shniu/blog/206386

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值