Mats de Waard Mats de Waard - 1 month ago 28
Python Question

Pytesseract traceback error "file not found"

I'm trying to use pytesseract for OCR.

I have installed google tesseract 3.03

I have installed pytesseract 0.1.6

I am running Python 3.5.1

I am running Windows 8

Tesseract is also in my path (I can call it from anywhere in a normal CMD and it will return the help function)


And this is the code I try to execute:

try:
import Image
except ImportError:
from PIL import Image
import pytesseract

im=Image.open('C:/Users/NeusAap/Google Drive/School/Jaar 1/Periode 1/Programming/Miniproject/GarageProject/scripts/test.png')
print(pytesseract.image_to_string(im))


But it returns this error:

Traceback (most recent call last):
File "C:/Users/NeusAap/Google Drive/School/Jaar 1/Periode 1/Programming/Miniproject/GarageProject/scripts/main.py", line 8, in <module>
print(pytesseract.image_to_string(im))
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string
config=config)
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract
stderr=subprocess.PIPE)
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

Process finished with exit code 1


I know that both tesseract and pytesseract work because if I run this from CMD:

python pytesseract.py -l eng+nld test.png


It does work, and returns me the characters as expected.

What am I doing wrong?

Thanks in advance!

Mats de Waard

Answer

I finally got it working. Seems like everything was set up right, and that I was calling everything correctly, but I needed to reboot Windows, because the files could not be found by Python.

I forgot that windows debugging always starts with a reboot :P