ImportError: libjpeg.so.8: cannot open shared object file: No such file or directory

ImportError: libjpeg.so.8: cannot open shared object file: No such file or directory

还有一个类似的问题: PIL - libjpeg.so.8: cannot open shared object file: No such file or directory

但我得到的输出略有不同:

$ python manage.py               
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    execute_from_command_line(sys.argv)
  File "some_virtualenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "some_virtualenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 327, in execute
    django.setup()
  File "some_virtualenv/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "some_virtualenv/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "some_virtualenv/lib/python3.5/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "some_virtualenv/lib64/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 "some_django_project/some_django_app/models.py", line 25, in <module>
    from versatileimagefield.fields import VersatileImageField
  File "some_virtualenv/lib/python3.5/site-packages/versatileimagefield/fields.py", line 11, in <module>
    from .files import VersatileImageFieldFile, VersatileImageFileDescriptor
  File "some_virtualenv/lib/python3.5/site-packages/versatileimagefield/files.py", line 11, in <module>
    from .mixins import VersatileImageMixIn
  File "some_virtualenv/lib/python3.5/site-packages/versatileimagefield/mixins.py", line 8, in <module>
    from .datastructures import FilterLibrary
  File "some_virtualenv/lib/python3.5/site-packages/versatileimagefield/datastructures/__init__.py", line 3, in <module>
    from .sizedimage import SizedImage
  File "some_virtualenv/lib/python3.5/site-packages/versatileimagefield/datastructures/sizedimage.py", line 11, in <module>
    from .base import ProcessedImage
  File "some_virtualenv/lib/python3.5/site-packages/versatileimagefield/datastructures/base.py", line 3, in <module>
    from PIL import Image
  File "some_virtualenv/lib/python3.5/site-packages/PIL/Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: libjpeg.so.8: cannot open shared object file: No such file or directory

我的第 25 行 models.py:

from versatileimagefield.fields import VersatileImageField

Django 版本:

$ pip freeze | grep Django   
Django==1.9.5

抱枕版型:

$ pip freeze | grep Pillow
Pillow==3.2.0

系统:

$ uname -a                        
Linux zbookhack-gableroux-local 4.9.3-200.fc25.x86_64 #1 SMP Fri Jan 13  01:01:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

libjpeg 安装在我的系统上

$ sudo dnf install libjpeg
Package libjpeg-turbo-1.5.1-0.fc25.x86_64 is already installed, skipping.
Package libjpeg-turbo-1.5.1-0.fc25.i686 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!

Pillow3.3 及更高版本 中修复了此问题,升级包对我有用:)

pip install Pillow==4

pip install Pillow --upgrade

github 上有一些相关的 Pillow 问题:

#1952 #2123 #2167