找不到PIL

2024-05-08 02:25:17 发布

您现在位置:Python中文网/ 问答频道 /正文

RuntimeError: NotImplementedError('Unable to find the Python Python Imaging Library.  Please view the SDK documentation for details about installing PIL on your system.',).

通过谷歌应用引擎日志我得到了这个错误。 我想上传一张图片。 我已经安装了PIL,但仍然找不到它的显示。 我已经安装好了

^{pr2}$

这是应用程序yaml在

application: uniqueappid
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /static
  static_dir: static

- url: /.*
  script: main.app

libraries:
- name: jinja2
  version: latest
- name: PIL
  version: 1.1.7

Tags: thetonameviewurlpilversionlibrary
1条回答
网友
1楼 · 发布于 2024-05-08 02:25:17

如果由于任何原因无法加载PIL库,则会发生这种情况。我在运行OSX,所以你的解决方案可能会有所不同,但也许描述一下我所做的会帮助其他人。在

对我来说,问题是我的python2.7.13forosx没有附带yaml库,因此需要图像库失败了。运行此程序可以解决我的问题:

sudo pip install pyyaml

要使images API在本地运行,我需要的安装总数如下:

^{pr2}$

这些包需要全局安装,因为它们将由API服务器使用。使用-t在本地安装包,并将库目录添加到appengine_config.py中,都不起作用。在

除此之外,我还需要在我的应用程序yaml即使你的枕头版本不一样:

^{3}$

如前所述,加载库的问题可能不同,因此我是如何发现缺少的yaml依赖关系的:

从下面最后一行调用堆栈中,我解释了我的应用程序引擎库驻留在/Applications/google-cloud-sdk/platform/google_appengine中:

File "/Applications/google-cloud-sdk/platform/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 259, in _MakeRealSyncCall

通过阅读代码,我发现负责检测PIL是否安装的模块是google.appengine.api.images.images_stub,因此我做了以下操作:

cd /Applications/google-cloud-sdk/platform/google_appengine/
python -c 'from google.appengine.api.images import images_stub'

。。导致以下错误:

Traceback (most recent call last):
[... callstack omitted ...]
ImportError: No module named yaml

这使我能够发现导入失败是因为缺少yaml模块。在

相关问题 更多 >