找不到 Python PIL 库。Google App Engine
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1170898/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to find the Python PIL library.Google App Engine
提问by benasio
Installed the Google App Engine SDK.Python 2.6 perfect. Wanted to go into images, and test locally.Installed PIL
完美安装了Google App Engine SDK.Python 2.6。想要进入图像,并在本地进行测试。安装了 PIL
Installed Python, then ran the PIL install, worked this time.
安装 Python,然后运行 PIL 安装,这次工作了。
Things seemed good, but trying to do localhost image manipulation gives:
事情看起来不错,但是尝试进行 localhost 图像处理会给出:
"NotImplementedError: Unable to find the Python PIL library. Please
view the SDK documentation for details about installing PIL on your system."
System : winxp
系统:winxp
采纳答案by Blair Conrad
We're probably going to need more information, so here are some questions and things to try.
我们可能需要更多信息,所以这里有一些问题和尝试。
How are you trying to access the PIL? Are you trying to use the google.appengine.api.images module, or PIL directly? It sounds like the former, but it's not clear.
您如何尝试访问 PIL?您是否尝试直接使用 google.appengine.api.images 模块或 PIL?听起来像前者,但不清楚。
Did you follow the App Engine instructions?
您是否按照App Engine 说明进行操作?
Post code, if you can.
如果可以,请发布代码。
Perhaps the most important thing to try: see if you can use PIL from a non-App Engine script. Just write a quick Python script that accesses it and see how that goes. Something like:
也许最重要的尝试是:看看您是否可以从非 App Engine 脚本使用 PIL。只需编写一个快速访问它的 Python 脚本,然后看看效果如何。就像是:
import Image
im = Image.open('filename.png')
im.show()
If that doesn't work, it's not surprising that Google App Engine wouldn't work with PIL.
如果这不起作用,那么 Google App Engine 不能与 PIL 一起工作也就不足为奇了。
回答by peawormsworth
I took a while to get PIL working. Mainly because I forgot to tell app engine to load it in the yaml file:
我花了一段时间让 PIL 工作。主要是因为我忘记告诉应用引擎在 yaml 文件中加载它:
libraries:
- name: PIL
version: 1.1.7
Maybe this step is obvious, but I did not see it documented well on google documentation and I found all kinds of messages here stating that PIL was not available on app engine. I want to confirm that PIL is running on app engine.
也许这一步很明显,但我没有看到它在 google 文档中记录得很好,我在这里发现了各种消息,指出 PIL 在应用引擎上不可用。我想确认 PIL 正在应用引擎上运行。
回答by sastanin
As far as I know Google AppEngine does not allow to use PIL directly, but instead provides a limited Images API.
据我所知 Google AppEngine 不允许直接使用 PIL,而是提供了有限的Images API。
It can resize/rotate/crop and flip images. More or less what Picasaweb can do. But it cannot create new images or do complex things like adding text, drawing etc.
它可以调整大小/旋转/裁剪和翻转图像。Picasaweb 或多或少可以做什么。但它无法创建新图像或执行添加文本、绘图等复杂操作。
回答by Torsten Becker
On Ubuntu with python2.5 the following helps:
在使用 python2.5 的 Ubuntu 上,以下帮助:
new repo: ppa.launchpad.net/fkrull/deadsnakes/ubuntu
新仓库:ppa.launchpad.net/fkrull/deadsnakes/ubuntu
sudo apt-get install python2.5 python2.5-dev libjpeg62 libjpeg62-dev
sudo apt-get install python2.5 python2.5-dev libjpeg62 libjpeg62-dev
untar: http://effbot.org/media/downloads/Imaging-1.1.6.tar.gz
解压:http: //effbot.org/media/downloads/Imaging-1.1.6.tar.gz
cd Imaging-1.1.6
cd 成像-1.1.6
edit setup.py line 38: JPEG_ROOT = libinclude("/usr/lib")
编辑 setup.py 第 38 行:JPEG_ROOT = libinclude("/usr/lib")
sudo python2.5 setup.py install
须藤 python2.5 setup.py 安装
Done
完毕
回答by amv
For OSX 10.11.6 and Python 2.7.13 I needed to install pyyaml
in addition to Pillow
globallyin order for the launched API server to pick them up:
对于 OSX 10.11.6 和 Python 2.7.13 pyyaml
,除了Pillow
全局安装之外,我还需要安装,以便启动的 API 服务器能够获取它们:
sudo pip install Pillow pyyaml
After this I had to specifically add the PIL version 1.1.7
into the app.yaml libraries, even though the Pillow version was NOT 1.1.7:
在此之后,我必须专门将 PIL 版本添加1.1.7
到 app.yaml 库中,即使 Pillow 版本不是 1.1.7:
libraries:
- name: PIL
version: 1.1.7
The way I found that I was missing the yaml
library is described in more detail in this comment:
yaml
在此评论中更详细地描述了我发现我缺少库的方式:
回答by Jim Carroll
If you clear your GAE log window (assuming you're using the launcher) then restart your server, you might see something in the log. In my case I got
如果您清除 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
So I could tell that I didn't link well enough with the JPEG library.
所以我可以说我与 JPEG 库的链接不够好。
回答by Ido Ran
I've run into the same issue on Windows machine and then I've notice in the App Engine Docs:
我在 Windows 机器上遇到了同样的问题,然后我在 App Engine Docs 中注意到:
Note: In addition to the Images API, you can also use the transforms provided in the Python Imaging Library (PIL) in your Python 2.7 app. You simply declare the library in the libraries section of the app.yaml file. However, if you wish to use PIL in your local environment (using the development server) you must also download and install PILor pillow locally.
注意:除了图像 API,您还可以在 Python 2.7 应用程序中使用 Python 图像库 (PIL) 中提供的转换。您只需在 app.yaml 文件的库部分声明库。但是,如果您希望在本地环境中使用 PIL(使用开发服务器),您还必须在本地下载并安装 PIL或 Pillow。
So just download PILand it will work.
所以只需下载 PIL就可以了。