While I'm using below code , getting Error as "WindowsError:[Error 2] The system cannot find the file specified". Please help me to get text from image.
from pytesseract import image_to_string
from PIL import Image
print image_to_string(Image.open(r'D:\\name.jpg'),lang='eng')
ERROR:
WindowsError Traceback (most recent call last) in () 2 from PIL import Image 3 ----> 4 print image_to_string(Image.open(r'D:\name.jpg'),lang='eng')
C:\ProgramData\Anaconda2\lib\site-packages\pytesseract\pytesseract.pyc in image_to_string(image, lang, boxes, config) 120 lang=lang, 121 boxes=boxes, --> 122 config=config) 123 if status: 124 errors = get_errors(error_string)
C:\ProgramData\Anaconda2\lib\site-packages\pytesseract\pytesseract.pyc in run_tesseract(input_filename, output_filename_base, lang, boxes, config) 44 command += shlex.split(config) 45 ---> 46 proc = subprocess.Popen(command, stderr=subprocess.PIPE) 47 status = proc.wait() 48 error_string = proc.stderr.read()
C:\ProgramData\Anaconda2\lib\subprocess.pyc in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags) 388 p2cread, p2cwrite, 389 c2pread, c2pwrite, --> 390 errread, errwrite) 391 except Exception: 392 # Preserve original exception in case os.close raises.
C:\ProgramData\Anaconda2\lib\subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) 638 env, 639 cwd, --> 640 startupinfo) 641 except pywintypes.error, e: 642 # Translate pywintypes.error to WindowsError, which is
WindowsError: [Error 2] The system cannot find the file specified
D:\name.jpg
? Could you test to see if you can work with an image on your current folder instead of on `D:`?