尽管安装了所需的库(在ubuntu上使用python3),Pyautogui函数LocateOnScreen仍出现错误。请帮我解决

2024-05-16 12:01:04 发布

您现在位置:Python中文网/ 问答频道 /正文

解释器中使用的函数:

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

Tags: inpyhomeinitlibpackageslocalline
1条回答
网友
1楼 · 发布于 2024-05-16 12:01:04

错误消息说:

"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()这样的函数

相关问题 更多 >