为什么会出现 `ModuleNotFoundError: No module named 'Image'` 错误?

4
当我运行我的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。这样可以吗?


1
ImagePIL子模块。它的完全限定名称是 PIL.Image - MisterMiyagi
1个回答

4
你需要从 PIL 包中导入它们:
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont

# use Image

或者说,另一种选择是:

import PIL

# use PIL.Image

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接