Failed to get text from image using pytesseract
While I am using the code below, getting Error as "WindowsError: [Error 2] The system cannot find the file specified." Please help me get the text from the image.
from pytesseract import image_to_string
from PIL import Image
print image_to_string(Image.open(r'D:\\name.jpg'),lang='eng')
ERROR:
Tracing WindowsError (last 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 exception: 392 # Keep original exception if os.close is raised.
C: \ ProgramData \ Anaconda2 \ lib \ subprocess.pyc to _execute_child (self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, createflags, shell, to_close, p2cread, p2cwrite2, c2pread, c2pread errwrite) 638 env, 639 cwd, -> 640 startupinfo) 641 except pywintypes.error, e: 642 # Translate pywintypes.error to WindowsError which
WindowsError: [Error 2] The system cannot find the file specified
source to share