简体   繁体   English

错误:ModuleNotFoundError:没有名为“图像”的模块

[英]Error:ModuleNotFoundError: No module named 'Image'

I am getting the following error: 我收到以下错误:

ModuleNotFoundError: No module named 'Image' ModuleNotFoundError:没有名为“图像”的模块

while running the below script for OCR: 在运行以下OCR脚本时:

import Image
from tesseract import image_to_string


print(image_to_string(Image.open('marlboro.png'), lang='eng'))

I am using Spider through Anaconda and have Pillow installed. 我正在通过Anaconda使用Spider并安装了Pillow。

Have a look at the docs , where you can see some basic examples. 看一下docs ,您可以在其中看到一些基本示例。 In short: You need to specify that you are importing Image from PIL : 简而言之:您需要指定要从PIL导入Image

from PIL import Image

You should install pytesseract use pip (also see guide ): 您应该安装pytesseract use pip(另请参见指南 ):

pip install pytesseract

and then: 接着:

from PIL import Image
from pytesseract import image_to_string

print(image_to_string(Image.open('marlboro.png'), lang='eng'))

or use python cross-platform module tesseract : 或使用python跨平台模块tesseract

pip install tesseract

and use it as you have in your question: 并按照您的问题使用它:

from PIL import Image
from tesseract import image_to_string

print(image_to_string(Image.open('marlboro.png'), lang='eng'))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM