0

I'm using pytesseract in python 3.x and trying to convert an image into text.

Running the code:

from pytesseract import image_to_string
from PIL import Image

im = Image.open('image.bmp')
print(im)
print(image_to_string(im)

gives the output:

>>> ================================ RESTART ================================
>>> 
<PIL.BmpImagePlugin.BmpImageFile image mode=RGB size=563x558 at 0x2D9C350>
Traceback (most recent call last):
  File "C:\Users\ADMIN\Desktop\image.py", line 6, in <module>
    s= image_to_string(im)
  File "C:\Python34\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string
    config=config)
  File "C:\Python34\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract
    stderr=subprocess.PIPE)
  File "C:\Python34\lib\subprocess.py", line 848, in __init__
    restore_signals, start_new_session)
  File "C:\Python34\lib\subprocess.py", line 1104, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
>>> 

PIL seems to be loading the image just fine, but pytesseract is throwing FileNotFoundError and I have no idea why. Any help much appreciated!

user406579
  • 23
  • 3
  • Thanks, this was the solution. Odd that I didn't find that thread whilst searching for solutions though. – user406579 May 20 '17 at 02:31
  • Although tesseract runs now, it doesn't seem to be very effective. I can't get it to read anything except a test example I made in paint with the text tool just to make sure it was actually running. – user406579 May 20 '17 at 02:41
  • That's unfortunate, personally, I don't use tesseract, perhaps you can try this instead? http://stackoverflow.com/questions/6756820/python-pil-image-tostring – Taku May 20 '17 at 22:37
  • And this is the improved version of that app https://pypi.python.org/pypi/tesserocr so I suppose you can use this instead – Taku May 20 '17 at 22:39

0 Answers0