App Engine SDK PIL error

2020-05-06 07:58发布

I am developing Python application for Google App Engine on MacOS and I am having troubles trying to setup PIL for local development. I am running Python 2.5 in virtualenv and I also installed PIL 1.1.7 in the virtualenv using pip:

pip install PIL

I can import it in python interpreter and everything seems ok, but when it is used by the App Engine SDK, the following error is raised:

File "/Users/user/Development/src/virtualenv/lib/python2.5/site-packages/PIL/PngImagePlugin.py", line 564, in _save
SystemError: Parent module 'PIL' not loaded

It appears that this error occurs when PIL imports ICCProfile, but it should also be caught by the except and handled properly. Here is the code from PngImagePlugin.py:

try:
    import ICCProfile
    p = ICCProfile.ICCProfile(im.info["icc_profile"])
    name = p.tags.desc.get("ASCII", p.tags.desc.get("Unicode", p.tags.desc.get("Macintosh", p.tags.desc.get("en", {}).get("US", "ICC Profile")))).encode("latin1", "replace")[:79]
except ImportError:
    name = "ICC Profile"

The suggestion I got, when searching for the solution, was that I should create PIL.pth file with a path to PIL, but this file already exists in the virtualenv in site-packages folder and the content of the file is:

PIL

Does anyone have any suggestion on how to fix it or what else could I try?

1条回答
forever°为你锁心
2楼-- · 2020-05-06 08:50

Try using Pillow instead of PIL.

Update 1

See this thread http://code.activestate.com/lists/python-image-sig/6543/

查看更多
登录 后发表回答