[Python] pyautogui not working on MacOS ('<' not supported between instances of 'str' and...

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

  1. Stack

    Stack Membro Participativo

    I`m trying to find an image on the screen using pyautoGUI on MacOS. The code i use is the following:

    import pyautogui

    img = 'name.png'

    img = pyautogui.locateCenterOnScreen(img)


    Can anyone help me? I was expecting to get the coordinates of the image, instead i got the error:

    Traceback (most recent call last):
    File "/Users/cliente/Documents/Personal/dofusBot/bot.py", line 9, in <module>
    img = pyautogui.locateCenterOnScreen(img)
    File "/Users/cliente/miniconda/envs/analytics/lib/python3.10/site-packages/pyautogui/__init__.py", line 172, in wrapper
    return wrappedFunction(*args, **kwargs)
    File "/Users/cliente/miniconda/envs/analytics/lib/python3.10/site-packages/pyautogui/__init__.py", line 204, in locateCenterOnScreen
    return pyscreeze.locateCenterOnScreen(*args, **kwargs)
    File "/Users/cliente/miniconda/envs/analytics/lib/python3.10/site-packages/pyscreeze/__init__.py", line 420, in locateCenterOnScreen
    coords = locateOnScreen(image, **kwargs)
    File "/Users/cliente/miniconda/envs/analytics/lib/python3.10/site-packages/pyscreeze/__init__.py", line 375, in locateOnScreen
    screenshotIm = screenshot(
    File "/Users/cliente/miniconda/envs/analytics/lib/python3.10/site-packages/pyscreeze/__init__.py", line 527, in _screenshot_osx
    if tuple(PIL__version__) < (6, 2, 1):
    TypeError: '<' not supported between instances of 'str' and 'int'

    Continue reading...

Compartilhe esta Página