[Python] pyautogui could not locate image exception even though it exists

Discussão em 'Python' iniciado por Stack, Junho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I am Using Pyautogui Library for image tracing for a long time. I don't know why but I just got a new laptop and it's not working for me at all. It throws the Image not found Error Even if image exists. I can guarantee that image path is also absolute Correct. Even I Tried a simple program Like I've Given Below But It Still Shows Me Error.

    Is There Anyone Who Can Help ? Really Appreciate It. Thank You!

    from pyautogui import *

    a = locateOnScreen("E:/Mark 7/Test.png")

    print(a)

    if not (a == None):

    print("Got Image")

    if(a==None):

    print("Oops!")



    When I Tried This, I got This Error

    Traceback (most recent call last):
    File "C:\Users\DELL INC\AppData\Roaming\Python\Python312\site-packages\pyautogui\__init__.py", line 172, in wrapper
    return wrappedFunction(*args, **kwargs)
    File "C:\Users\DELL INC\AppData\Roaming\Python\Python312\site-packages\pyautogui\__init__.py", line 210, in locateOnScreen
    return pyscreeze.locateOnScreen(*args, **kwargs)
    File "C:\Users\DELL INC\AppData\Roaming\Python\Python312\site-packages\pyscreeze\__init__.py", line 405, in locateOnScreen
    retVal = locate(image, screenshotIm, **kwargs)
    File "C:\Users\DELL INC\AppData\Roaming\Python\Python312\site-packages\pyscreeze\__init__.py", line 383, in locate
    points = tuple(locateAll(needleImage, haystackImage, **kwargs))
    File "C:\Users\DELL INC\AppData\Roaming\Python\Python312\site-packages\pyscreeze\__init__.py", line 371, in _locateAll_pillow
    raise ImageNotFoundException('Could not locate the image.')
    pyscreeze.ImageNotFoundException: Could not locate the image.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "E:\Mark 7\Test.py", line 3, in <module>
    a = locateOnScreen("E:\\Mark 7\\Test.png")
    File "C:\Users\DELL INC\AppData\Roaming\Python\Python312\site-packages\pyautogui\__init__.py", line 174, in wrapper
    raise ImageNotFoundException # Raise PyAutoGUI's ImageNotFoundException.
    pyautogui.ImageNotFoundException

    Continue reading...

Compartilhe esta Página