无法找到Python PIL库.Google App Engine

时间:2009-07-23 10:31:43

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

安装了Google App Engine SDK.Python 2.6完美版。 想进入图像,并在本地测试。安装PIL

安装了Python,然后运行PIL安装,这次工作。

事情似乎很好,但尝试进行localhost图像操作 给出:

"NotImplementedError: Unable to find the Python PIL library.  Please
 view the SDK documentation for details about installing PIL on your system."

系统:winxp

7 个答案:

答案 0 :(得分:10)

我花了一些时间让PIL工作。主要是因为我忘了告诉app引擎将它加载到yaml文件中:

 libraries:
     - name:    PIL
     version: 1.1.7

也许这一步很明显,但我没有看到它在谷歌文档中记录得很好,我在这里发现了各种消息,说明PIL在app引擎上不可用。我想确认PIL正在app引擎上运行。

答案 1 :(得分:4)

我们可能需要更多信息,所以这里有一些问题和尝试。

您是如何尝试访问PIL的?您是否尝试直接使用google.appengine.api.images模块或PIL?这听起来像前者,但目前尚不清楚。

您是否关注the App Engine instructions

邮政编码,如果可以的话。

尝试最重要的事情可能是:查看是否可以使用非App Engine脚本中的PIL。只需编写一个快速的Python脚本来访问它,看看它是怎么回事。类似的东西:

import Image
im = Image.open('filename.png')
im.show()

如果这不起作用,Google App Engine无法与PIL配合使用就不足为奇了。

答案 2 :(得分:4)

据我所知,Google AppEngine不允许直接使用PIL,而是提供有限的Images API

它可以调整大小/旋转/裁剪和翻转图像。或多或少Picasaweb可以做什么。但它无法创建新图像或执行复杂的操作,如添加文本,绘图等。

答案 3 :(得分:3)

在Ubuntu上使用python2.5时,有以下帮助:

新回购:ppa.launchpad.net/fkrull/deadsnakes/ubuntu

sudo apt-get install python2.5 python2.5-dev libjpeg62 libjpeg62-dev

解压:http://effbot.org/media/downloads/Imaging-1.1.6.tar.gz

cd Imaging-1.1.6

编辑setup.py第38行:JPEG_ROOT = libinclude(“/ usr / lib”)

sudo python2.5 setup.py install

完成

答案 4 :(得分:3)

对于OSX 10.11.6和Python 2.7.13,除了pyyaml 全局之外,我还需要安装Pillow,以便启动的API服务器接收它们:

sudo pip install Pillow pyyaml

在此之后,我必须将PIL版本1.1.7专门添加到app.yaml库中,即使Pillow版本不是1.1.7

libraries:
- name: PIL
  version: 1.1.7

我发现我错过yaml库的方式在本评论中有更详细的描述:

PIL cannot be found

答案 5 :(得分:1)

如果清除GAE日志窗口(假设您正在使用启动器)然后重新启动服务器,您可能会在日志中看到一些内容。在我的情况下,我得到了

    WARNING  2011-01-27 21:04:11,856 dev_appserver.py:3698] 
Could not initialize images API; you are likely missing the Python "PIL" module. 
ImportError: dlopen(/Library/Python/2.6/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart
  Referenced from: /Library/Python/2.6/site-packages/PIL/_imaging.so

所以我可以说我没有与JPEG库连接得很好。

答案 6 :(得分:0)

我在Windows机器上遇到了同样的问题然后我在App Engine Docs中注意到了:

  

注意:除了Images API,您还可以使用转换   在Python 2.7应用程序的Python Imaging Library(PIL)中提供。   您只需在库的库部分声明库   app.yaml文件。但是,如果您希望在当地使用PIL   环境(使用开发服务器)您还必须download and install PIL或在当地枕头。

所以只需download PIL即可。