首页 > 解决方案 > 无法从“PIL”错误中导入名称“_imaging”

问题描述

我在我的 python 项目中使用 Pillow-6.1.0,我试图在其中导入 ImageGrab() 函数,但是我不断收到以下错误:

cannot import name '_imaging' from 'PIL' 

我目前正在使用 Python 3.7 并在 Visual Studios 上编辑代码(不确定 IDE 是否可能参与错误,因为我没有太多经验)

我也在运行 Windows,所以我看到的一些需要 Linux 的解决方案对我不起作用。

我试过的:

  1. 卸载并重新安装 Pillow

  2. 删除 Python37-32/Lib/site-packages 文件夹中带有“PIL”的所有内容并卸载 Pillow 并重新安装

  3. 将 Pillow 模块直接移动到我的项目文件夹中

  4. 将 ImageGrab.py 直接移动到我的项目文件夹中

  5. 更新了我的枕头模块

我所有重新安装 Pillow 都是通过 pip 命令

其他可能相关的信息:

  1. ImageGrab() 不是我无法导入的唯一模块,我也无法导入 Image 模块

  2. 我可以成功导入 PIL 模块,但无法通过 IDE 中的“from PIL import some_PIL_module”命令访问其中的模块

  3. 当我通过 Visual Studios IDE 运行我的代码时,如果我直接在 python 终端中输入命令“from PIL import ImageGrab”,它会成功运行而没有错误

这是在我的代码中给我错误的行

from PIL import ImageGrab;

我希望它可以毫无问题地导入,但我收到以下错误:

cannot import name '_imaging' from 'PIL'

标签: pythonvisual-studiopython-imaging-libraryimaging

解决方案


推荐阅读