我试图捕捉当前画面的一部分检测屏幕上的一些数字,但是当在运行的代码得到这个错误:蟒蛇FileNotFoundError使用pytesseract
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')))
请有人告诉我为什么,以及如何解决它?
可能重复:\ [错误2 \]系统找不到指定的文件“不解析”(http://stackoverflow.com/questions/18757127/windowserror-error-2-the-system-cannot-find-the-file-specified-is-not-resol) –
我试图删除线时调用子进程(另一个答案建议添加它来修复),并在你的建议中添加一些该anwser的行,但它仍然错误:(。@PavneetSingh – AlphaWolf