首页 > 解决方案 > 访问被拒绝,Windows 中的权限错误 [win 错误 5]

问题描述

每当我运行此代码时,都会发生此错误。我尝试了 Python -m pip install – 用户 pyforms,但对我没有任何帮助我正在使用 Anaconda-> Jupyter Notebook,Python 3.7,

我已经导入了 pytesseract

请解释是否可以实际导致错误的原因

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")))

错误:

   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

标签: pythonimage-processingpython-tesseract

解决方案


您的 tesseract_cmd 似乎不正确。如果我理解正确,它应该是 Tesseract 可执行文件的路径。

资源


推荐阅读