0

I am running a python test framework that uses Tesseract.

When I run a test that uses tesseract however I get the following error :

WindowsError: [Error 2] The system cannot find the file specified

I managed to go through the logs and found it breaks at:

File "C:\Python27\lib\subprocess.py", line 212, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)

The subprocess is called by a non python lib command from the framework

def process_frame_text(single_char=False):
    tess_list = ['tesseract', 'tmp/ocr_image.png', 'tmp/ocr_output']
    tess_list += ['-psm', '10'] if single_char else []
    check_output(tess_list, stderr=STDOUT)[:-1]

I have installed windows Tesseract on my machine at C:\Program Files x86\Tesseract-OCR

Appreciate you ideas.

Thanks

0

1 Answer 1

5

Apparently, subprocess module is not able to find tesseract.exe and invoke it from Windows shell. If path to the executable, C:\Program Files x86\Tesseract-OCR, is not added to Windows environment variables, then modify tess_list to provide full file path.

EDIT:

For your case, should set:

  • TESSDATA_PREFIX = C:\Program Files x86\Tesseract\tessdata that points to the trained language data files.
  • C:\Program Files (x86)\Tesseract-OCR which is the tesseract.exe file path should be added to Windows system PATH variable as an addition value, such as PATH=%PATH%;"C:\Program Files (x86)\Tesseract-OCR" if added by command for temporary use.
Sign up to request clarification or add additional context in comments.

4 Comments

Thats exactly what the problem is, thank you. Ive added the path directly.
It is already an environment variable TESSDATA_PREFIX: C:/Program Files (x86)/Tesseract-OCR/tesseract.exe so im going to investigate why that doesnt work
@mogoli, check my additional info in Answer under EDIT. Your TESSDATA_PREFIX setting is incorrect.
Worked for me, I just did the second bullet after the "EDIT"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.