1

I have a Django blog-type app with articles. I'd like to attach images to these articles. When I try to do that, I get the following error and traceback:

Environment:


Request Method: POST
Request URL: http://[site].com/admin/paper/article/1/

Django Version: 1.8.3
Python Version: 3.4.1
Installed Applications:
('sorl.thumbnail',
 'django_mobile',
 'event_ticker',
 'paper',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django_mobile.middleware.MobileDetectionMiddleware',
 'django_mobile.middleware.SetFlavourMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware')


Traceback:
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/contrib/admin/options.py" in wrapper
  616.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/utils/decorators.py" in _wrapped_view
  110.                     response = view_func(request, *args, **kwargs)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/contrib/admin/sites.py" in inner
  233.             return view(request, *args, **kwargs)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/contrib/admin/options.py" in change_view
  1519.         return self.changeform_view(request, object_id, form_url, extra_context)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/utils/decorators.py" in _wrapper
  34.             return bound_func(*args, **kwargs)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/utils/decorators.py" in _wrapped_view
  110.                     response = view_func(request, *args, **kwargs)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/utils/decorators.py" in bound_func
  30.                 return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/local/lib/python3.4/contextlib.py" in inner
  30.                 return func(*args, **kwds)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/contrib/admin/options.py" in changeform_view
  1459.             if form.is_valid():
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/forms/forms.py" in is_valid
  184.         return self.is_bound and not self.errors
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/forms/forms.py" in errors
  176.             self.full_clean()
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/forms/forms.py" in full_clean
  392.         self._clean_fields()
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/forms/forms.py" in _clean_fields
  405.                     value = field.clean(value, initial)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/forms/fields.py" in clean
  644.         return super(FileField, self).clean(data)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/forms/fields.py" in clean
  162.         value = self.to_python(value)
File "/home/me/webapps/bs/lib/python3.4/Django-1.8.3-py3.4.egg/django/forms/fields.py" in to_python
  674.         from PIL import Image

Exception Type: ImportError at /admin/paper/article/1/
Exception Value: No module named 'PIL'

I am running a virtualenv, here's the result of a pip freeze

Django==1.8.3
django-mobile==0.5.0
image==1.4.0
pbr==1.1.1
Pillow==2.9.0
Pillow-PIL==0.1.dev0
psycopg2==2.6.1
six==1.9.0
sorl-thumbnail==12.3
stevedore==1.5.0
uWSGI==2.0.11
versiontools==1.9.1
virtualenv==13.0.3
virtualenv-clone==0.2.5
virtualenvwrapper==4.6.0
wheel==0.24.0

I could provide a million other details. I don't have PIL installed and I can't install it because the virtualenv I'm using is running python3.4, which won't even install PIL correctly because it's so old. When I try to install PIL (using the --allow-unverified option I learned from searching on here) I get an error involving the print command.

I'm really confused. I thought Django had dropped PIL entirely? But it's showing up in a Django file as a required module? Do I need to use another version of python to install it or am I missing something extremely obvious?

yarlesp
  • 23
  • 2
  • http://stackoverflow.com/questions/6579995/django-no-module-named-pil/6787493#comment7759714_6579995 – chandu Aug 03 '15 at 06:43
  • @chandu I saw that answer. I really don't want to modify Django files directly just to get this to work. That seems like a really bad idea. Plus, this could be one of hundreds of import statements that I'd have to modify. If there's really no other way I'll do this but what a headache... – yarlesp Aug 03 '15 at 18:45

0 Answers0