我收到错误 pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it is not in your path。我在这个出现前几分钟测试了我的程序,它运行良好。然后我再次测试它,它一直显示这个错误。我不知道该怎么办。这是我的代码:
from PIL import ImageGrab
import cv2
import pytesseract
import numpy as np
from tkinter import Tk
from tkinter.filedialog import askopenfilename
ask = input("Do you want to ocr in realtime or choose a picture (r/p)?")
if ask == 'r':
while True:
screen = np.array(ImageGrab.grab(bbox=(700, 300, 1600, 1000)))
# print('Frame took {} seconds'.format(time.time()-last_time))
cv2.imshow('window', screen)
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
print(pytesseract.image_to_string(screen, lang='eng', config='--psm 6'))
if ask == 'p':
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(pytesseract.image_to_string(filename, lang='eng', config='--psm 6'))