问题描述
我已使用以下命令在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)
image = PIL.Image.open("Capture Image.PNG")
错误:未定义变量:'PIL'Python(未定义变量)
我尝试了下面列出的类似帖子,但是它们并没有帮助我解决问题。
- Pip install Pillow: "no module named Pillow?"
- Pillow installed,but getting "no module named pillow" when importing
- Python pillow module not importing properly
关于, 吉兰萨卡
解决方法
@ dragon2fly非常感谢您解决此问题。请参考以下代码段以获取完整的源代码。
from PIL import Image
image = Image.open("Capture_image.png")
print(image.size)