在 Django 项目中,Python 说 Pillow 未安装但已安装

时间:2021-04-20 07:21:12

标签: python django pycharm windows-10 python-3.9

将 Python 3.8 升级到 3.9 后,发生了此错误并表示未安装枕头。我尝试卸载并重新安装枕头,但没有奏效。

我在 Windows 10 专业版上使用 Django 3.1。

pip freeze 的输出也附上了。

错误信息如下:

ERRORS:

magazine.Magazine.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
        HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip install Pillow".
post.Posts.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
        HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip install Pillow".
post.Sample.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
        HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip install Pillow".
post.Workers.avatar: (fields.E210) Cannot use ImageField because Pillow is not installed.
        HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip install Pillow".
product.Products.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
        HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip install Pillow".

enter image description here enter image description here

2 个答案:

答案 0 :(得分:1)

这是警告,因为旧版本的 pip 正在重命名无法删除的文件夹,用 tilda ~ 替换第一个字母。

在您的 C:\..\python38-32\lib\site-packages 中有一个名为 ~illow... 的文件夹。

当我删除该文件夹并重新安装 python -m pip Pillow 时,它起作用了。

我有同样的错误,这个 post 解决了问题。

答案 1 :(得分:0)

1.激活虚拟环境(你的env路径)。\Scripts\activate 2.运行Django应用

这会奏效。