简体   繁体   English

pytesseract 给出错误 PermissionError: [WinError 5] Access is denied

[英]pytesseract gives an error PermissionError: [WinError 5] Access is denied

I'm using pytesseract in Python for pdf.我在 Python 中使用 pytesseract for pdf。 But I'm getting permission error in windows 10. I have install tesseract-ocr-w64-setup-v5.0.0-alpha.20200328.exe from https://github.com/UB-Mannheim/tesseract/wiki I have also poppler-20.09.0 files.但是我在 Windows 10 中遇到了权限错误。我已经从https://github.com/UB-Mannheim/tesseract/wiki安装了 tesseract-ocr-w64-setup-v5.0.0-alpha.20200328.exe 我也有poppler-20.09.0 文件。 and I`m using python 3.8.0我正在使用 python 3.8.0

import pdf2image
import PyPDF2
import os
try:
   from PIL import Image
except ImportError:
   import Image
import pytesseract

pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR'

def pdf_to_img(pdf_file):
    print('pdf_file = ', pdf_file)
    return pdf2image.convert_from_path(pdf_file, dpi=200, fmt='jpg',
                                   poppler_path=r'F:\lokesh\resume_script\poppler-20.09.0\bin')


def ocr_core(file):
    text = pytesseract.image_to_string(file,)
    return text


def print_pages(pdf_file):
    images = pdf_to_img(pdf_file)
    for pg, img in enumerate(images):
        print(ocr_core(img))


print_pages("aa.pdf")

when I run this code.当我运行此代码时。 it gives this error.它给出了这个错误。

Traceback (most recent call last):
File "test.py", line 84, in <module>
  print_pages("aa.pdf")
File "test.py", line 81, in print_pages
  print(ocr_core(img))
File "test.py", line 74, in ocr_core
  text = pytesseract.image_to_string(file,)
File "F:\python\lib\site-packages\pytesseract\pytesseract.py", line 344, in image_to_string
  return {
File "F:\python\lib\site-packages\pytesseract\pytesseract.py", line 347, in <lambda>
  Output.STRING: lambda: run_and_get_output(*args),
File "F:\python\lib\site-packages\pytesseract\pytesseract.py", line 258, in run_and_get_output
  run_tesseract(**kwargs)
File "F:\python\lib\site-packages\pytesseract\pytesseract.py", line 229, in run_tesseract
  raise e
File "F:\python\lib\site-packages\pytesseract\pytesseract.py", line 226, in run_tesseract
  proc = subprocess.Popen(cmd_args, **subprocess_args())
File "F:\python\lib\subprocess.py", line 854, in __init__
  self._execute_child(args, executable, preexec_fn, close_fds,
File "F:\python\lib\subprocess.py", line 1307, in _execute_child
  hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied

how can we solve this error in windows我们如何解决 Windows 中的这个错误

pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR'

需要是

pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Pytesseract 因 PermissionError 失败:[WinError 5] 由于不可删除的文件,访问被拒绝 - Pytesseract is failing with PermissionError: [WinError 5] Access is denied due to undeletable file pytesseract PermissionError:[WinError 5] CreateProcess 中的访问被拒绝(Windows 10) - pytesseract PermissionError: [WinError 5] Access is denied in CreateProcess (Windows 10) PermissionError: [WinError 5] 访问被拒绝 - PermissionError: [WinError 5] Access is denied PermissionError: [WinError 5] 访问被拒绝 - PermissionError: [WinError 5] Access denied Python 错误:PermissionError:[WinError 5] 访问被拒绝 - Python Error: PermissionError: [WinError 5] Access is denied WinError 5:访问被拒绝 PyTesseract - WinError 5:Access denied PyTesseract Python-PermissionError:[WinError 5]访问被拒绝: - Python - PermissionError: [WinError 5] Access is denied: PermissionError: [WinError 5] 访问在 Python 中被拒绝 - PermissionError: [WinError 5] Access is denied in Python 执行以下代码时出错(PermissionError: [WinError 5] Access is denied) - Getting Error (PermissionError: [WinError 5] Access is denied) when Execute below code PermissionError: [WinError 5] 访问被拒绝 jupyter 内核 - PermissionError: [WinError 5] Access is denied jupyter kernel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM