Reputation: 31061
There are actually a couple of questions here. For what I'm doing, I'm doing a basic image upload with Django 1.1 and Google App Engine. Here is my form class:
class UploadPictureForm(forms.Form):
picture = forms.ImageField()
And then on submit, I have the following code:
def handle_picture(request):
form = UploadPictureForm(request.POST, request.FILES)
if form.is_valid():
save_picture(request.FILES['picture']
I get the following error:
Exception Type: ImportError
Exception Value: No module named PIL
Exception Location: /Library/Python/2.6/site-packages/django/forms/fields.py in clean, line 495
Python Executable: /usr/bin/python2.6
Python Version: 2.6.1
Python Path: [..., '/Library/Python/2.6/site-packages', '/Library/Python/2.6/site-packages/PIL']
and I've installed PIL in the site-packages
directory and if I run python from the command line, I can import PIL with import PIL
SO question #1 is why doesn't this work? Is GAE doing something that's keeping this from working? The second thing is that I notice GAE has some Image APIs. Should I be using those instead? All of this is somewhat new for me.
Upvotes: 2
Views: 864
Reputation: 29644
More, I'm not quite sure you can use PIL at all with GAE. It's a C-based library and therefore it's a no-no for GAE (which requires custom packages to be pure-Python only) (there's even a ticket for this issue).
PIL is used by the development server locally to simulate all image api calls. You can found the installation instructions here
Upvotes: 0
Reputation: 101149
Can you show us the full stacktrace? Based on what you provided, there's several options:
Upvotes: 0
Reputation: 97161
For starters, you shouldn't use GAE with Python 2.6. Google App Engine is created with 2.5 in mind and it usually breaks in multiple ways on 2.6.
More, I'm not quite sure you can use PIL at all with GAE. It's a C-based library and therefore it's a no-no for GAE (which requires custom packages to be pure-Python only) (there's even a ticket for this issue).
That's what images API was created for. It still uses PIL as a backend (at least on the user side), but offers a 'safe' subset of it.
Upvotes: 3