没有名为PIL的模块和没有名为Image

时间:2017-05-04 16:49:46

标签: django python-3.x pillow sorl-thumbnail

我在虚拟服务器上使用nginx + uwsgi + django作为我的网站。也可以使用sorl-thumbnail。

在此字符串中:

    th = get_thumbnail(p.photo, '445x300', crop='center', quality=99)

我收到了这个错误:

    Traceback (most recent call last):
    File "/home/nafuser/nafVenv/lib/python3.5/site-        packages/sorl/thumbnail/engines/pil_engine.py", line 8, in <module>
from PIL import Image, ImageFile, ImageDraw, ImageFilter
    ImportError: No module named 'PIL'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/sorl/thumbnail/helpers.py", line 66, in get_module_class
mod = import_module(mod_name)
      File "/home/nafuser/nafVenv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 986, in _gcd_import
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 665, in exec_module
      File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/sorl/thumbnail/engines/pil_engine.py", line 10, in <module>
        import Image
    ImportError: No module named 'Image'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
      File "./portfolio/views.py", line 49, in portfolio
th = get_thumbnail(p.photo, '445x300', crop='center', quality=99)
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/sorl/thumbnail/shortcuts.py", line 8, in get_thumbnail
return default.backend.get_thumbnail(file_, geometry_string, **options)
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/sorl/thumbnail/base.py", line 103, in get_thumbnail
source_image = default.engine.get_image(source)
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/django/utils/functional.py", line 234, in inner
self._setup()
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/sorl/thumbnail/default.py", line 19, in _setup
self._wrapped = get_module_class(settings.THUMBNAIL_ENGINE)()
      File "/home/nafuser/nafVenv/lib/python3.5/site-packages/sorl/thumbnail/helpers.py", line 68, in get_module_class
raise ImproperlyConfigured(('Error importing module %s: "%s"' % (mod_name, e)))
    django.core.exceptions.ImproperlyConfigured: Error importing module                         sorl.thumbnail.engines.pil_engine: "No module named 'Image'"

我已经重新安装了枕头。在我当地的Django服务器上,它可以正常工作。

如何解决这个错误?

0 个答案:

没有答案