安装的 PILLOW 模块未识别为在 Python 3 中导入
Installed PILLOW Module is not Identifying to Import in Python 3
我已经使用以下命令在 Windows 8.1 中为 Python 3 安装了 PILLOW 模块。
pip install pillow
安装成功。
不幸的是,当我尝试使用以下语句在其中导入图像子模块时出现导入错误。
from PIL import image
错误: ImportError:无法从 'PIL' 导入名称 'image' (C:\Program Files\Python38\lib\site-packages\PIL_init_.py)
尽管下面的语句给出了 'PIL' 的错误。
image = PIL.Image.open("Capture Image.PNG")
错误:未定义的变量:“PIL”Python(undefined-variable)
我试过下面列出的类似帖子,但它们没有帮助我解决问题。
- Pip install Pillow: "no module named Pillow?"
- Pillow installed, but getting "no module named pillow" when importing
你能解释一下我在这里遗漏了什么吗?
此致,
奇兰塔卡
@dragon2fly 非常感谢您解决问题。请参考下面的代码片段以获取完整的源代码。
from PIL import Image
image = Image.open("Capture_image.png")
print(image.size)
我已经使用以下命令在 Windows 8.1 中为 Python 3 安装了 PILLOW 模块。
pip install pillow
安装成功。
不幸的是,当我尝试使用以下语句在其中导入图像子模块时出现导入错误。
from PIL import image
错误: ImportError:无法从 'PIL' 导入名称 'image' (C:\Program Files\Python38\lib\site-packages\PIL_init_.py)
尽管下面的语句给出了 'PIL' 的错误。
image = PIL.Image.open("Capture Image.PNG")
错误:未定义的变量:“PIL”Python(undefined-variable)
我试过下面列出的类似帖子,但它们没有帮助我解决问题。
- Pip install Pillow: "no module named Pillow?"
- Pillow installed, but getting "no module named pillow" when importing
你能解释一下我在这里遗漏了什么吗?
此致, 奇兰塔卡
@dragon2fly 非常感谢您解决问题。请参考下面的代码片段以获取完整的源代码。
from PIL import Image
image = Image.open("Capture_image.png")
print(image.size)