问题描述
解释器中使用的函数:
pyautogui.locateOnScreen('zoom_pic.png')
错误是:-
Traceback (most recent call last):
File "<pyshell#10>",line 1,in <module>
pyautogui.locateOnScreen('zoom_pic.png')
File "/home/aaryan/.local/lib/python3.8/site-packages/pyautogui/__init__.py",line 175,in wrapper
return wrappedFunction(*args,**kwargs)
File "/home/aaryan/.local/lib/python3.8/site-packages/pyautogui/__init__.py",line 213,in locateOnScreen
return pyscreeze.locateOnScreen(*args,**kwargs)
File "/home/aaryan/.local/lib/python3.8/site-packages/pyscreeze/__init__.py",line 371,in locateOnScreen
screenshotIm = screenshot(region=None) # the locateall() function must handle cropping to return accurate coordinates,so don't pass a region here.
File "/home/aaryan/.local/lib/python3.8/site-packages/pyscreeze/__init__.py",line 498,in _screenshot_linux
raise NotImplementedError('"scrot" must be installed to use screenshot functions in Linux. Run: sudo apt-get install scrot')
NotImplementedError: "scrot" must be installed to use screenshot functions in Linux. Run: sudo apt-get install scrot
解决方法
错误消息说:
"scrot" must be installed to use screenshot functions in Linux. Run: sudo apt-get install scrot
您是否在终端中尝试过 sudo apt-get install scrot
?这应该允许您运行 pyautogui.locateOnScreen()
和 pyautogui.screenshot()
之类的函数。