I am getting the following error:
ModuleNotFoundError: No module named 'Image'
while running the below script for 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.
Have a look at the docs , where you can see some basic examples. In short: You need to specify that you are importing Image
from PIL
:
from PIL import Image
You should install pytesseract
use pip (also see guide ):
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
:
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'))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.