Mats de Waard Mats de Waard - 1 year ago 173
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:

import Image
except ImportError:
from PIL import Image
import pytesseract'C:/Users/NeusAap/Google Drive/School/Jaar 1/Periode 1/Programming/Miniproject/GarageProject/scripts/test.png')

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/", line 8, in <module>
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pytesseract\", line 161, in image_to_string
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pytesseract\", line 94, in run_tesseract
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\", line 947, in __init__
restore_signals, start_new_session)
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\", line 1224, in _execute_child
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 -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 Source

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