0

Whenever I run this code this error occurs. I tried Python -m pip install – user pyforms too but nothing worked for me I am using Anaconda-> Jupyter Notebook, Python 3.7,

I have imported pytesseract already

Please explain if you can what actually causes the error

import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = (r'C:\Users\Yuvraj\Anaconda3\Scripts')
print(pytesseract.image_to_string(Image.open("ECYPA.png")))

Error:

   PermissionError                           Traceback (most recent call last)
  <ipython-input-1-77d1e9761914> in <module>
       2 from PIL import Image
       3 pytesseract.pytesseract.tesseract_cmd = (r'C:\Users\Yuvraj\Anaconda3\Scripts')
 ----> 4 print(pytesseract.image_to_string(Image.open("ECYPA.png")))

 ~\Anaconda3\lib\site-packages\pytesseract\pytesseract.py in image_to_string(image, lang, config, 
 nice, output_type, timeout)
     348         Output.DICT: lambda: {'text': run_and_get_output(*args)},
     349         Output.STRING: lambda: run_and_get_output(*args),
 --> 350     }[output_type]()
     351 
     352 

   ~\Anaconda3\lib\site-packages\pytesseract\pytesseract.py in <lambda>()
     347         Output.BYTES: lambda: run_and_get_output(*(args + [True])),
     348         Output.DICT: lambda: {'text': run_and_get_output(*args)},
 --> 349         Output.STRING: lambda: run_and_get_output(*args),
     350     }[output_type]()
     351 

 ~\Anaconda3\lib\site-packages\pytesseract\pytesseract.py in run_and_get_output(image, extension, 
 lang, config, nice, timeout, return_bytes)
     258         }
     259 
 --> 260         run_tesseract(**kwargs)
     261         filename = kwargs['output_filename_base'] + extsep + extension
     262         with open(filename, 'rb') as output_file:

   ~\Anaconda3\lib\site-packages\pytesseract\pytesseract.py in run_tesseract(input_filename, 
   output_filename_base, extension, lang, config, nice, timeout)
     229     except OSError as e:
     230         if e.errno != ENOENT:
 --> 231             raise e
     232         raise TesseractNotFoundError()
     233 

  ~\Anaconda3\lib\site-packages\pytesseract\pytesseract.py in run_tesseract(input_filename, 
   output_filename_base, extension, lang, config, nice, timeout)
     226 
     227     try:
 --> 228         proc = subprocess.Popen(cmd_args, **subprocess_args())
     229     except OSError as e:
     230         if e.errno != ENOENT:

  ~\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, 
  preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, 
   restore_signals, start_new_session, pass_fds, encoding, errors, text)
     773                                 c2pread, c2pwrite,
     774                                 errread, errwrite,
 --> 775                                 restore_signals, start_new_session)
     776         except:
     777             # Cleanup if the child failed starting.

   ~\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, 
    pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, 
   errread, errwrite, unused_restore_signals, unused_start_new_session)
    1176                                          env,
    1177                                          os.fspath(cwd) if cwd is not None else None,
--> 1178                                          startupinfo)
    1179             finally:
    1180                 # Child is launched. Close the parent's copy of those pipe

    PermissionError: [WinError 5] Access is denied
David Buck
  • 3,752
  • 35
  • 31
  • 35

1 Answers1

0

It seems like your tesseract_cmd is incorrect. It should be the path to the Tesseract executable if I understand it correctly.

Source

speckOfDust
  • 76
  • 1
  • 8