如何解决PermissionError:[WinError 5]在tesseract.exe的anaconda spyder中拒绝访问
runfile('E:/python/tensorflow.py',wdir='E:/python')
Traceback (most recent call last):
File "<ipython-input-1-c970ef5c8f56>",line 1,in <module>
runfile('E:/python/tensorflow.py',wdir='E:/python')
File "C:\Users\Harsh\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py",line 827,in runfile
execfile(filename,namespace)
File "C:\Users\Harsh\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py",line 110,in execfile
exec(compile(f.read(),filename,'exec'),namespace)
File "E:/python/tensorflow.py",line 9,in <module>
import tensorflow as tf
File "E:\python\tensorflow.py",line 18,in <module>
text = pytesseract.image_to_string(img)
File "C:\Users\Harsh\Anaconda3\lib\site-packages\pytesseract\pytesseract.py",line 358,in image_to_string
}[output_type]()
File "C:\Users\Harsh\Anaconda3\lib\site-packages\pytesseract\pytesseract.py",line 357,in <lambda>
Output.STRING: lambda: run_and_get_output(*args),File "C:\Users\Harsh\Anaconda3\lib\site-packages\pytesseract\pytesseract.py",line 266,in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\Harsh\Anaconda3\lib\site-packages\pytesseract\pytesseract.py",line 237,in run_tesseract
raise e
File "C:\Users\Harsh\Anaconda3\lib\site-packages\pytesseract\pytesseract.py",line 234,in run_tesseract
proc = subprocess.Popen(cmd_args,**subprocess_args())
File "C:\Users\Harsh\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py",line 143,in __init__
super(SubprocessPopen,self).__init__(*args,**kwargs)
File "C:\Users\Harsh\Anaconda3\lib\subprocess.py",line 775,in __init__
restore_signals,start_new_session)
File "C:\Users\Harsh\Anaconda3\lib\subprocess.py",line 1178,in _execute_child
startupinfo)
PermissionError: [WinError 5] Access is denied
我的代码
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 19 15:17:41 2020
@author: Harsh
"""
import cv2
#import tesseract as te
import tensorflow as tf
import numpy as np
import pytesseract
pytesseract.pytesseract.tesseract_cmd= r"C:\\Users\\Harsh\\Anaconda3\\envs\\tesseract\\Library\\bin"
img = cv2.imread("sample1.jpg")
text = pytesseract.image_to_string(img)
#print(pytesseract.image_to_string(Image.open("sample1.jpg")))
cv2.imshow("Img",img)
print(text)
cv2.waitKey(0)
解决方法
您的pytesseract.pytesseract.tesseract_cmd
是错误的。阅读pytesseract文档如何正确设置。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。