我试图捕获当前屏幕的一部分以检测屏幕上的某个数字,但是当代码运行时出现此错误:
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/bot/detect_num.py", line 12, in <module>
print(pytesseract.image_to_string(Image.open('test.jpg')))
File "C:\Python35\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string
config=config)
File "C:\Python35\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract
stderr=subprocess.PIPE)
File "C:\Python35\lib\subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "C:\Python35\lib\subprocess.py", line 1224, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
源代码:
import pyscreenshot as ImageGrab
from PIL import Image
import subprocess
from pytesseract import *
if __name__=="__main__":
im = ImageGrab.grab(bbox=(1349, 34, 1357, 45))
im = im.convert('1')
im.save('test.jpg', 'JPEG')
im.show()
print(pytesseract.image_to_string(Image.open('test.jpg')))
请有人告诉我为什么,以及如何解决?