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

In Django project, Python says Pillow is not installed but it is installed

升级 Python 3.8 到 3.9 后,出现此错误,提示未安装枕头。我尝试卸载并重新安装 pillow,但没有用。

我在 Windows 10 pro 上使用 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".

1.Activate 虚拟环境(你的环境路径)。\Scripts\activate 2.Run Django 应用程序

这会起作用。

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

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

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

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