App Engine SDK PIL错误

时间:2012-06-20 09:53:02

标签: python image google-app-engine python-imaging-library

我正在为MacOS上的Google App Engine开发Python应用程序,我在尝试为本地开发设置PIL时遇到了麻烦。我在virtualenv中运行Python 2.5,我还使用pip在virtualenv中安装了PIL 1.1.7:

pip install PIL

我可以在python解释器中导入它,一切似乎都可以,但是当它被App Engine SDK使用时,会引发以下错误:

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

当PIL导入ICCProfile时,似乎会发生此错误,但它也应该被except捕获并正确处理。这是来自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"

我在搜索解决方案时得到的建议是,我应该使用PIL路径创建PIL.pth文件,但此文件已存在于site-packages文件夹中的virtualenv中,文件内容为:

PIL

有没有人对如何修复它或我还能尝试什么有任何建议?

1 个答案:

答案 0 :(得分:2)

尝试使用Pillow代替PIL。

更新1

请参阅此帖子http://code.activestate.com/lists/python-image-sig/6543/