raise ImageNotFoundException # Raise PyAutoGUI‘s ImageNotFoundException

报错解释:

raise ImageNotFoundException 是一个自定义的异常抛出语句,通常在Python程序中出现图片未找到的情况时使用。这个异常是由 PyAutoGUI 库抛出的,PyAutoGUI 是一个用于控制鼠标和键盘的 Python 库,在使用其中的图片识别功能时,如果无法找到指定的图片,就会抛出这个异常。
解决:
1.更新 PyAutoGUI 库
2.降低图片信任度
3.检查图片清晰度、尝试更换图片
4.使用try语法捕获异常

try:
    wechatPostion = pyautogui.locateOnScreen("wechat.jpg",confidence=0.8)
    print(wechatPostion)
    pyautogui.click(wechatPostion)
except pyautogui.ImageNotFoundException:
    print("Sorry I cannot locate wechat.jpg")
    ```
Traceback (most recent call last): File "C:\Users\czadmin\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyautogui\__init__.py", line 172, in wrapper return wrappedFunction(*args, **kwargs) File "C:\Users\czadmin\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyautogui\__init__.py", line 210, in locateOnScreen return pyscreeze.locateOnScreen(*args, **kwargs) ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "C:\Users\czadmin\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyscreeze\__init__.py", line 405, in locateOnScreen retVal = locate(image, screenshotIm, **kwargs) File "C:\Users\czadmin\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyscreeze\__init__.py", line 383, in locate points = tuple(locateAll(needleImage, haystackImage, **kwargs)) File "C:\Users\czadmin\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyscreeze\__init__.py", line 371, in _locateAll_pillow raise ImageNotFoundException(&#39;Could not locate the image.&#39;) pyscreeze.ImageNotFoundException: Could not locate the image. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\czadmin\PyCharmMiscProject\csdl.py", line 11, in <module> btm = pyautogui.locateOnScreen(pic) File "C:\Users\czadmin\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyautogui\__init__.py", line 174, in wrapper raise ImageNotFoundException # Raise PyAutoGUI&#39;s ImageNotFoundException. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pyautogui.ImageNotFoundException
03-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

兰博lamb

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值