1

when i run the following code for pytesseract

>>> import pytesseract
>>> import Image
>>> print pytesseract.image_to_string("plate.png")

it shows the below error

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    print pytesseract.image_to_string("plate.png")
  File "/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.py", line 137, in image_to_string
    image.save(input_file_name)
AttributeError: 'str' object has no attribute 'save'

what does this error mean? How can i correct this?

thanks in advance

jeena rita
  • 13
  • 1
  • 1
  • 4

1 Answers1

4

Pass an image object instead of file path (string):

import pytesseract
import Image

im = Image.open("plate.png")
print pytesseract.image_to_string(im)
falsetru
  • 357,413
  • 63
  • 732
  • 636