Search code examples
pythonpyautogui

Can't locate image on python


I try to locate an image on my screen. But it always shows this -

Traceback (most recent call last):
  File "C:/Users/MerazulIslam/Desktop/ZOOM_BOT/bot.py", line 20, in <module>
    find_btn = pyautogui.locateOnScreen(r'C:\Users\MerazulIslam\Desktop\ZOOM_BOT\Capture.PNG', confidene=0.5)
  File "C:\Users\MerazulIslam\AppData\Roaming\Python\Python38\site-packages\pyautogui\__init__.py", line 175, in wrapper
    return wrappedFunction(*args, **kwargs)
  File "C:\Users\MerazulIslam\AppData\Roaming\Python\Python38\site-packages\pyautogui\__init__.py", line 213, in locateOnScreen
    return pyscreeze.locateOnScreen(*args, **kwargs)
  File "C:\Users\MerazulIslam\AppData\Roaming\Python\Python38\site-packages\pyscreeze\__init__.py", line 359, in locateOnScreen
    screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate coordinates, so don't pass a region here.
  File "C:\Users\MerazulIslam\AppData\Roaming\Python\Python38\site-packages\pyscreeze\__init__.py", line 134, in wrapper
    raise PyScreezeException('The Pillow package is required to use this function.')
pyscreeze.PyScreezeException: The Pillow package is required to use this function.

my code-

import pyautogui

find_btn = pyautogui.locateOnScreen(r'C:\Users\MerazulIslam\Desktop\bot\Capture.PNG')
print(find_btn)

Please help!


Solution

  • You can just try to reinstall pyautogui with all dependencies to make sure nothing missing:

    pip install --upgrade --force-reinstall pyautogui