已安装的PILLOW模块无法识别要在Python 3中导入

问题描述

我已使用以下命令在Windows 8.1中为Python 3安装了PILLOW模块。

pip install pillow

安装成功。

不幸的是,当我尝试使用以下语句在其中导入图像子模块时,出现了导入错误

from PIL import image

错误 ImportError:无法从“ PIL”中导入名称“图像”(C:\ Program Files \ python38 \ lib \ site-packages \ PIL_ init _。 py)

尽管下面的陈述给我一个'PIL'错误

image = PIL.Image.open("Capture Image.PNG")

错误未定义变量:'PIL'Python(未定义变量)

我尝试了下面列出的类似帖子,但是它们并没有帮助我解决问题。

  1. Pip install Pillow: "no module named Pillow?"
  2. Pillow installed,but getting "no module named pillow" when importing
  3. Python pillow module not importing properly

能否请您解释我在这里缺少的内容

关于, 吉兰萨卡

解决方法

@ dragon2fly非常感谢您解决此问题。请参考以下代码段以获取完整的源代码。

from PIL import Image

image = Image.open("Capture_image.png")

print(image.size)