monkeyhouse
monkeyhouse

Reputation: 2896

Google App Engine PIL support

I am getting error when using PIL on the cloud in google app engine

ImportError: cannot import name _imaging
at <module>():66 (Image.py:66 in /base/data...../lib/PIL)
at <module>():6 (storage.py:6 in /base/data/home/...../modules/common)
....
at <module>():1 (main.py:1 in /base/data/home/apps/..../....456)

The application seems to load fine locally.

I list PIL as a dependnecy in the app.yaml libraries section

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

I also used pip install PIL -t /lib to save it to my ./lib folder for local development

Additional info: I am using PIL because it is an imaging library that has google app engine support https://cloud.google.com/appengine/docs/python/tools/built-in-libraries-27

Upvotes: 2

Views: 1151

Answers (2)

minocha
minocha

Reputation: 1044

remove the PIL module from the lib folder that you installed on your own.

go to app.yaml and paste this under the libraries section (if there isn't one paste this whole) -

libraries: - name: PIL version: latest

call the appengine based module by -

from PIL import Image

Upvotes: 1

Dan Cornilescu
Dan Cornilescu

Reputation: 39824

You're effectively attempting to run your copy of the PIL library instead of the one provided (see the file paths in the stack trace, which include details about your app which you edited out).

Not only that you don't need to upload the PIL lib, you actually should not upload it as the one provided is likely a version specifically customized for the GAE python sandbox.

So make sure the local PIL installation doesn't place the library or a link to it anywhere inside the app's dir, to prevent it from being accidentally vendored into your app and uploaded with it.

Upvotes: 0

Related Questions