|
カテゴリ:Debian
Debian11にしてPyAutoGUIのスクリプトを走らせてみると、画像出待ち処理でエラーになる。
$ python3 --version Python 3.9.2 $ pip3 list | grep 'GUI' PyAutoGUI 0.9.53 変更した箇所 #import pyscreeze #from pyscreeze import ImageNotFoundException #pyscreeze.USE IMAGE NOT FOUND EXCEPTION = True pyautogui.useImageNotFoundException() pyscreeze というモジュールのImageNotFoundExceptionは使うな、ということらしい。で、ImageNotFoundException()という関数を使えと。これを使うと locateで画像の座標を探して見つからなかったらpyautogui.ImageNotFoundExceptionが立つらしい。あと、各所のImageNotFoundExceptionをpyautogui.ImageNotFoundExceptionに書き換え 参考例 https://www.fixes.pub/program/872186.html これの一番下のが最新の書き方らしい。 """ import pyautogui # force use of ImageNotFoundException pyautogui.useImageNotFoundException() try: location= pyautogui.locateOnScreen('foo.png') print('image found') except pyautogui.ImageNotFoundException: print('ImageNotFoundException: image not found') """https://github.com/asweigart/pyautogui/blob/master/pyautogui/__init__.py class ImageNotFoundException(PyAutoGUIException): """ This exception is the PyAutoGUI version of PyScreeze's `ImageNotFoundException`, which is raised when a locate*() function call is unable to find an image. Ideally, `pyscreeze.ImageNotFoundException` should never be raised by PyAutoGUI. """ お気に入りの記事を「いいね!」で応援しよう
Last updated
2022.01.12 11:36:46
[Debian] カテゴリの最新記事
|