What steps will reproduce the problem? 1. Import pytesser into a script that's on a different path 2. Try and run pytesser.image_to_string() 3.
What is the expected output? What do you see instead? This is how it crashes: Traceback (most recent call last): File "z:\scripts\bruker\grabMicroStar.py", line 107, in <module> text = pytesser.image_to_string(snap).strip() File "z:\scripts\bruker\pytesser\pytesser.py", line 41, in image_to_string call_tesseract(scratch_image_name, scratch_text_name_root) File "z:\scripts\bruker\pytesser\pytesser.py", line 31, in call_tesseract proc = subprocess.Popen(args) File "c:\programs\Python26\lib\subprocess.py", line 633, in init errread, errwrite) File "c:\programs\Python26\lib\subprocess.py", line 842, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified
What version of the product are you using? On what operating system? v0.0.1
Please provide any additional information below.
The problem is that it doesn't know where to find the tesseract.exe executable if current working directory is not the same as that of the script (likely).
The fix is: in pytesser.py, add the following lines after tesseract_exe_name, which figure out the path:
=========================================
if 'pytesser' in sys.modules: tesseract_exe_path = sys.modules['pytesser'].path[0] else: tesseract_exe_path = os.getcwd() tesseract_exe_name = os.path.join(tesseract_exe_path,tesseract_exe_name)
=========================================
Comment #1
Posted on Dec 21, 2012 by Grumpy Kangarooin this code the line : tesseract_exe_path = sys.modules['pytesser'].path[0] return: Traceback (most recent call last): File "", line 1, in sys.modules['pytesser'].path[0] AttributeError: 'module' object has no attribute 'path'
Status: New
Labels:
Type-Defect
Priority-Medium