python - Django SystemCheckError 说 Pillow 未安装,但 Pillow 已安装

标签 python django python-2.7 ubuntu python-imaging-library

当我运行 python manage.py runserver ,一切开始都很好,但后来我得到一个 SystemCheckError说明 Pillow 未安装;但是,这台机器上肯定安装了 Pillow。

这是我收到的错误:

Performing system checks...

Unhandled exception in thread started by Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 110, in inner_run self.validate(display_num_errors=True) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 468, in validate return self.check(app_configs=app_configs, display_num_errors=display_num_errors) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 527, in check raise SystemCheckError(msg) django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS: recipes.Recipes.primary_image: (fields.E210) Cannot use ImageField because Pillow is not installed. HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install Pillow". recipes.Recipes.thumbnail_image: (fields.E210) Cannot use ImageField because Pillow is not installed. HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install Pillow".



我在 Ubuntu 机器上运行它。有什么想法吗?

最佳答案

在您的代码中,如果您曾在任何地方尝试使用导入语句,如 import pillowfrom pillow import ... ,将这些语句更改为:

from PIL import ...

或者
import PIL

PIL 即不再维护 Python 图像库, Pillow 改为使用。为了保持向后兼容性,PIL模块名称用于导入。

关于python - Django SystemCheckError 说 Pillow 未安装,但 Pillow 已安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32492183/

相关文章:

python - 无法从 'Dataset' 导入名称 'mlflow.entities'

django - django-filter 页面启动时结果列表为空

django - Django 1.4 datefield和sqlite问题

python - 将迭代器链接到平面迭代器

python - 使用 module_from_spec 加载的 python 类中缺少源信息

python - 如何只打印 BeautifulSoup 值?

python - 如何从 Django 中的表单调用 Python 函数?

python - Mac OS 上的 pybluez 安装错误

python - 为什么具有相同数据的列表具有不同的大小?

python - 对多级组的组内观察进行计数/分配组顺序?