I am trying to execute the following code
from pytesser import * import Image i="C:/Documents and Settings/Administrator/Desktop/attachments/R1PNDTCB.jpg" print i im = Image.open(i.strip()) text = image_to_string(im) print text
I get the following error
C:/Documents and Settings/Administrator/Desktop/attachments/R1PNDTCB.jpg Traceback (most recent call last): File "C:\Python27\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 322, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "C:\Python27\Lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "C:\Python27\Lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 655, in run exec cmd in globals, locals File "C:\Documents and Settings\Administrator\Desktop\attachments\ocr.py", line 1, in <module> from pytesser import * File "C:\Python27\lib\site-packages\PIL\Image.py", line 1952, in open fp = __builtin__.open(fp, "rb") IOError: [Errno 2] No such file or directory: 'C:/Documents and Settings/Administrator/Desktop/attachments/R1PNDTCB.jpg'
Can someone explain what I'm doing wrong here.
Renamed the image file. Dumped the python file and images to a new folder. Shift the folder to drive E Now the code is as follows:
from pytesser import * import Image import os i=os.path.join("E:\\","ocr","a.jpg") print i im = Image.open(i.strip()) text = image_to_string(im) print text
Now the error is as follows:
E:\ocr\a.jpg Traceback (most recent call last): File "or.py", line 8, in <module> text = image_to_string(im) File "C:\Python27\lib\pytesser.py", line 31, in image_to_string call_tesseract(scratch_image_name, scratch_text_name_root) File "C:\Python27\lib\pytesser.py", line 21, in call_tesseract proc = subprocess.Popen(args) File "C:\Python27\lib\subprocess.py", line 679, in __init__ errread, errwrite) File "C:\Python27\lib\subprocess.py", line 893, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified