我正在尝试使用pytesseract的run_and_get_output功能。但它给了我:
PermissionError:[Errno 13]权限被拒绝:'C:\User\yp270\AppData\Local\Temp\tess_0va90z8x。'
我正在使用:python 3.7.5 pytesseract 0.3.1 tesseract 3.05.02
我试过:在系统环境变量设置pytesseract. pytesseract中设置TESSDATA_PREFIX到我的tessdata目录。tesseract_cmd我的tesseract可执行文件
我似乎错误时pytesseract试图打开一些输出文件文件"C:\用户\yp270\AppData\本地\程序\Python\Python37\lib\site-包\pytesseract\pytesseract.py",第260行,run_and_get_output
文件"C:\用户\yp270\AppData\本地\程序\Python\Python37\lib\site-包\pytesseract\pytesseract.py",第260行,在
使用open(filename,'rb')作为output_file:
PermissionError:[Errno 13]权限被拒绝:'C:\User\yp270\AppData\Local\Temp\tess_5nau69o0。'
但是,除此之外,它们在使用image_to_string、image_to_data、image_to_osd等功能时没有问题。他们工作得非常好。这个问题只出现在run_and_get_output功能上。
有人能告诉我问题出在哪里吗???
代码:
import pytesseract
pytesseract.pytesseract.tesseract_cmd = 'C:\\Users\\yp270\\AppData\\Local\\Tesseract-OCR\\tesseract.exe'
from PIL import Image
img = Image.open('image_path')
boxes = pytesseract.image(img)
您是否尝试过安装不同版本的Tesseract?我在使用tesseract v5.0.0时遇到了与您相同的错误,但切换到tesseract v4.0.0后一切正常。
我使用tesseract-ocr-w64-setup-v4.0.0.20181030. exe从旧版本部分在https://github.com/UB-Mannheim/tesseract/wiki