PIL cannot be found

2019-05-30 19:13发布

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

Through google app engine log i am getting this error. i m trying to upload a image. i have installed PIL but still its showing cannot find. i have installed it in

C:\Python27\Lib\site-packages.

This is the 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条回答
地球回转人心会变
2楼-- · 2019-05-30 19:45

This happens if the PIL library can not be loaded for ANY reason. I am running OSX so the solution for you might be different for you, but maybe describing what I did will help others.

For me the problem was that my Python 2.7.13 for OSX did not ship with a yaml library, and requiring the images library failed because of that. Running this fixed the issue for me:

sudo pip install pyyaml

The total installs I needed to get the images API working locally was the following:

sudo pip install Pillow pyyaml

The packages need to be installed globally, as they will be used by the API server. Installing the packages locally with -t and adding the library directory to appengine_config.py DID NOT WORK.

In addition to this I needed to have the version fixed as 1.1.7 in my app.yaml even though your Pillow version will not be the same:

libraries:
- name: PIL
  version: 1.1.7

As mentioned, your problem with loading the library might be different, so here is how I discovered my missing yaml dependency:

From the following last callstack line I interpreted that my app engine libraries reside in /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

By reading the code I figured out that the module which is responsible for detecting if PIL is installed is google.appengine.api.images.images_stub, so I did the following:

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

.. which resulted in the following error:

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

This allowed me to figure out that the import was failing because of the missing yaml module.

查看更多
登录 后发表回答