PyAutoGUI 在 linux 上定位屏幕函数时出错

PyAutoGUI locate on screen function giving error on linux

当 运行 pyautogui.locateOnScreen() 函数时,它给我以下错误:

scrot: invalid option -- 'z'

有谁知道为什么会这样? 我安装了 scrot 0.8,终端中的 运行 scrot a.png 工作正常。 运行 scrot -z 给出相同的 scrot: invalid option -- 'z' 错误信息。 任何帮助表示赞赏。

您可以安全地忽略它,或者如果它打扰您,请分叉或提交 PR 到 pyscreeze

pyautogui depends on the pyscreeze package to take cross-platform screenshots. On Linux, pyscreeze uses a command-line utility called scrot

当 pyscreeze 弹出 scrot 时,它 passes -z。这在 some 版本的 scrot 中指定了 Prevent beeping,但并不总是可用。例如,它在 Fedora 的 scrot-0.8-21.fc31.x86_64.

中丢失

但是 invalid option -- 'z' 不是致命错误。您可以通过 运行 $ scrot -z 验证这一点,并看到一个新的带时间戳的屏幕截图出现在您的工作目录中,尽管有消息。或者从Python调用subprocess.call(['scrot', '-z']),看到return代码是0.