Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytesser does not find tesseract.exe from other working dir #8

Open
GoogleCodeExporter opened this issue Apr 11, 2015 · 1 comment
Open

Comments

@GoogleCodeExporter
Copy link

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)
#=========================================



Original issue reported on code.google.com by [email protected] on 15 Jun 2010 at 12:42

@GoogleCodeExporter
Copy link
Author

in this code the line :
tesseract_exe_path = sys.modules['pytesser'].__path__[0]
return:
Traceback (most recent call last):
  File "<pyshell#17>", line 1, in <module>
    sys.modules['pytesser'].__path__[0]
AttributeError: 'module' object has no attribute '__path__'

Original comment by [email protected] on 21 Dec 2012 at 8:18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant