Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

python - WinError 5:Access denied PyTesseract

I know this question has already been answered on this site, however, none of the solutions I looke up the internet seemed to work. Here's what I tried:

  • Giving all permissions to my python file
  • Changing PATH variable to point to my tesseract folder
  • Running IDLE as administrator and then executing the file from there

This error is quite bothering me now and I can't advance any further because of it.

Here's my code if that's going to help:

import pytesseract
import sys
import argparse
try:
    import Image
except ImportError:
    from PIL import Image
from subprocess import check_output
pytesseract.pytesseract.tesseract_cmd = 'C:Program FilesTesseract-OCR'
c=pytesseract.image_to_string(Image.open('img.png'))
print(c)

Traceback:

Traceback (most recent call last):
  File "C:UsersHpDesktopot.py", line 12, in <module>
    c=pytesseract.image_to_string(Image.open('captcha.png'))
  File "C:Pythonlibsite-packagespytesseractpytesseract.py", line 122, in image_to_string
config=config)
  File "C:Pythonlibsite-packagespytesseractpytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
  File "C:Pythonlibsubprocess.py", line 707, in __init__
restore_signals, start_new_session)
  File "C:Pythonlibsubprocess.py", line 992, in _execute_child
startupinfo)
PermissionError: [WinError 5] Accès refusé
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I suspect a few things, not sure about any though.

First and the most obvious, the path to Tesseract is not complete. It should be something like:

tesseract_cmd = 'C:\Program Files (x86)\Tesseract-OCR\tesseract'

I believe your path points to a directory/folder and not an executable, though only you can confirm that. Let me know if this is incorrect, I see something else too that doesn't seem right at first, but needs more investigation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...