无法找到PIL

时间:2014-04-01 09:43:48

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

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

通过谷歌应用引擎日志我收到此错误。 我正在尝试上传图片。 我已经安装了PIL,但它的显示仍无法找到。 我已将其安装在

C:\Python27\Lib\site-packages.

这是app.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

1 个答案:

答案 0 :(得分:0)

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

对我来说,问题是我的OS 2.7的Python 2.7.13没有附带yaml库,并且要求图像库因此而失败。运行这个解决了我的问题:

sudo pip install pyyaml

我需要在本地运行图像API所需的总安装次数如下:

sudo pip install Pillow pyyaml

需要全局安装软件包,因为它们将由API服务器使用。使用-t在本地安装软件包,并将库目录添加到appengine_config.py 无法正常工作

除此之外,我需要在我的app.yaml中将版本修复为1.1.7,即使你的Pillow版本不一样:

libraries:
- name: PIL
  version: 1.1.7

如上所述,加载库的问题可能有所不同,所以我在这里发现了我遗漏的yaml依赖项:

从下面的最后一个callstack行我解释我的app引擎库位于/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模块导致导入失败。

相关问题