module 'Image' has no attribute 'Image'

使用image_to_string(image)时出现如下错误:
module 'Image' has no attribute 'Image'_第1张图片
module ‘Image’ has no attribute ‘Image’
单独运行一下image_to_string函数发现如下问题:
module 'Image' has no attribute 'Image'_第2张图片
打开pytesseract.py文件,找到如下语句:
try:
import Image
except ImportError:
from PIL import Image
将上述语句调换一下顺序:
try:
from PIL import Image
except ImportError:
import Image
或者直接from PIL import Image
直接使用PIL.Image。

你可能感兴趣的:(python)