问题
I am using pytesseract to convert images to text. I successfully installed pytesseract with pip command. But when i run the script, it shows me error : No module named Tesseract
.
These are my codes :
from tesseract import image_to_string
image = Image.open('input-NEAREST.tif')
print image_to_string(image)
Error :
Traceback (most recent call last):
File "C:\Users\J's MAgic\Desktop\py\new1.py", line 1, in <module>
from tesseract import image_to_string
ImportError: No module named tesseract
回答1:
from PIL import Image
import pytesseract as tess
print tess.image_to_string(Image.open('3.png'), lang='tur')
Try this
回答2:
It should be not from tesseract import image_to_string
, but from pytesseract import image_to_string
.
Also, there are some problems with pip installation of pytesseract and lack of documentation of how properly install pytesseract, and I believe you will receive error when you will run your code. If you will be able to run your program that's great, but if you will receive error, do following: Download "tesseract-ocr-setup-3.02.02.exe" file from Sourceforge tesseract-ocr page
and install it simply running .exe file in some specific folder. After, add this folder to your PATH environment. Then try to run your program.
来源:https://stackoverflow.com/questions/29873886/error-using-pytesseract