Python Error pytesseract: PermissionError: [WinError 5] Access is denied

from PIL import Image
import pytesseract
pytesseract.pytesseract.tesseract_cmd = "C:\\Program Files (x86)\\Tesseract-OCR\\tessdata"
image = Image.open(r"E:\Python\ocr\venv\111.png")
code = pytesseract.image_to_string(image)
print(code)
 
  
E:\Python\ocr\venv\Scripts\python.exe E:/Python/ocr/ocr.py
Traceback (most recent call last):
  File "E:/Python/ocr/ocr.py", line 7, in 
    code = pytesseract.image_to_string(image)
  File "E:\Python\ocr\venv\lib\site-packages\pytesseract\pytesseract.py", line 136, in image_to_string
    nice=nice)
  File "E:\Python\ocr\venv\lib\site-packages\pytesseract\pytesseract.py", line 82, in run_tesseract
    proc = subprocess.Popen(command, stderr=subprocess.PIPE)
  File "C:\Program Files\Python36\Lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files\Python36\Lib\subprocess.py", line 992, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

一段简单的读取图片code,一开始包FileNotFoundError,于是添加tesseract_cmd路径,出现 [WinError 5] Access is denied

将tesseract_cmd更改为以下,问题解决

pytesseract.pytesseract.tesseract_cmd = "C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe"

你可能感兴趣的:(Python)