1

I've gone through all the other questions and answers about pytesseract but I am still getting the same error.

The message is the following

Traceback (most recent call last):
  File "C:\Users\VisitingFellows\Desktop\Python OCR\pytesseract.py", line 1, in <module>
    import pytesseract
  File "C:\Users\VisitingFellows\Desktop\Python OCR\pytesseract.py", line 11, in <module>
    text = pytesseract.image_to_string(Image.open('1928_-1_.jpg'), lang='ger')
AttributeError: module 'pytesseract' has no attribute 'image_to_string'

I don't get why image_to_string is not recognized as an attribute of pytesseract.

My code is the following

import pytesseract
from PIL import Image, ImageEnhance, ImageFilter

pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR'
im = Image.open("1928_-1.jpg") # the second one
im = im.filter(ImageFilter.MedianFilter())
enhancer = ImageEnhance.Contrast(im)
im = enhancer.enhance(2)
im = im.convert('1')
im.save('1928_-1_.jpg')
text = pytesseract.image_to_string(Image.open('1928_-1_.jpg'), lang='ger')
print(text)

and I am using Python 3.6 and pytesseract 0.2.0.

Anyone has solved the same problem?

PhDing
  • 163
  • 1
  • 9

1 Answers1

1

I think you have a local python file named pytesseract.py in your computer. If it is there, rename it something different and then try importing pytesseract.

Rahul Goswami
  • 535
  • 3
  • 14