我有一个带文章的Django博客类应用程序。我想在这些文章中添加图片。当我尝试这样做时,我得到以下错误和追溯:
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'
我正在运行virtualenv,这是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
我可以提供一百万个其他细节。我没有安装PIL而且我无法安装,因为我使用的virtualenv正在运行python3.4,它甚至不能正确安装PIL,因为它是如此旧。当我尝试安装PIL时(使用我在此处搜索时学到的--allow-unverified选项),我收到涉及print
命令的错误。
我真的很困惑。我以为Django完全丢掉了PIL?但它在Django文件中显示为必需模块?我需要使用另一个版本的python来安装它吗?还是我错过了一些非常明显的东西?