提问人:Uwe_98 提问时间:9/12/2019 最后编辑:ruoholaUwe_98 更新时间:2/5/2021 访问量:5706
为什么我会收到“ModuleNotFoundError: No module named 'Image'”错误?
Why am I getting a `ModuleNotFoundError: No module named 'Image'` error?
问:
当我运行 Python 脚本时,我收到以下消息:
ModuleNotFoundError: No module named 'Image'
我在 Linux Ubuntu 上运行 Python 3.6。 名为 Fax_simulator 的脚本包含:
import Image
# other code…
它位于:
/home/CVS/facsim/venv
我已经搜索了该模块,并找到了它:
/usr/lib/python3/dist-packages/PIL/Image.py
以下是代码的一些行:
import Image
import ImageDraw
import ImageFont
我必须安装它吗?如果是,如何?使用 PIP?我从 Python 3.6 获得了 PIP 版本 9.0.1。可以吗?
答:
4赞
ruohola
9/12/2019
#1
您需要从包中导入它们:PIL
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
# use Image
或者:
import PIL
# use PIL.Image
评论
Image
是 的子模块。其完全限定的名称是 。PIL
PIL.Image