3
from PIL import Image
from tesseract import image_to_string

print image_to_string(Image.open('C:\Users/Uzel/Desktop/pythonfoto/denklem.png'))
print image_to_string(Image.open('C:\Users/Uzel/Desktop/pythonfoto/denklem.png'), lang='eng')

I use this code after installing tesseract orc.

Traceback (most recent call last): File "C:\Users\Uzel\Documents\Visual Studio 2012\Projects\module3.py", line 28, in from tesseract import image_to_string ImportError: cannot import name image_to_string

I have this error. I tried pytesseract but I can not manage. Can we solve this problem. How? thank you.

Nida Uzel
  • 31
  • 4

1 Answers1

1

Below is a sample code with pytesseract.

import pytesseract 
from PIL import Image

pytesseract.pytesseract.tesseract_cmd = "C:/Program Files/Tesseract 4.0.0/tesseract.exe"
print(pytesseract.image_to_string(Image.open("./imagesStackoverflow/text.png"),
                                  lang="eng",boxes=False,config="--psm 3 --eom 3"))

The pytesseract.pytesseract.tesseract_cmd is to specific the EXE path explicitly in case the path hasn't been properly set up in Windows environment.

You need to have Tesseract installed in Windows and pytesseract installed with Python.

Hope this help.

thewaywewere
  • 8,128
  • 11
  • 41
  • 46