我只是将django-simple-captcha添加到我的apache2.2 + django1.8项目中
在python命令行中
from PIL.Image import *
没有显示任何错误
我已经将Python2.7 / site-packages中的所有文件都设置为chmod 777
但是当我启动服务器并请求一些页面时
会有错误日志:
mod_wsgi (pid=16530): Exception occurred processing WSGI script '/root/code/python/mysite/mysite/wsgi.py'.,
Traceback (most recent call last):, referer: http://xx.xx.xx.xx/
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__,
response = self.get_response(request), referer: http://xx.xx.xx.xx/
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_response,
response = self.handle_uncaught_exception(request, resolver, sys.exc_info()), referer:
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 264, in
if resolver.urlconf_module is None:, referer: http://xx.xx.xx.xx/
File "/usr/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in urlconf_module,
self._urlconf_module = import_module(self.urlconf_name), referer: http://xx.xx.xx.xx/
File "/usr/local/python27/lib/python2.7/importlib/__init__.py", line 37, in import_module, referer:
__import__(name), referer: http://xx.xx.xx.xx/
File "/root/code/python/mysite/mysite/urls.py", line 38, in <module>, referer: http://xx.xx.xx.xx/
url(r'^captcha/', include('captcha.urls')),, referer: http://xx.xx.xx.xx/
File "/usr/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 33, in include, referer:
urlconf_module = import_module(urlconf_module), referer: http://xx.xx.xx.xx/
File "/usr/local/python27/lib/python2.7/importlib/__init__.py", line 37, in import_module, referer:
__import__(name), referer: http://xx.xx.xx.xx/
File "/usr/local/lib/python2.7/site-packages/captcha/urls.py", line 6, in <module>, referer:
from captcha import views, referer: http://xx.xx.xx.xx/
File "/usr/local/lib/python2.7/site-packages/captcha/views.py", line 21, in <module>, referer:
import Image, referer: http://xx.xx.xx.xx/
File "/usr/local/lib/python2.7/site-packages/Image.py", line 1, in <module>, referer: http://xx.xx.xx.xx/
from PIL.Image import *, referer: http://xx.xx.xx.xx/
ImportError: No module named PIL.Image, referer: http://xx.xx.xx.xx/
有人能帮助我吗?
答案 0 :(得分:1)
您应该在项目的根路径中手动添加 PIL 库源。
在此处下载源http://www.pythonware.com/products/pil/#pil117并将PIL
目录复制到您的项目中。
答案 1 :(得分:0)
PIL未导入为PIL,您只需要直接导入Image
import Image
或
from Image import *