'How to fix PyAutoGUI AttributeError

I Have been trying to get PyAutoGUI to click one of the applications at the bottom of my screen using a very simple code. However, whenever I try to run this code I get an error that I believe is from the PyAutoGUI module I am using. The code is:

    import pyautogui as pag
    pag.click(500, 1100)

The error is:

File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pyautogui/__init__.py", line 588, in wrapper
    returnVal = wrappedFunction(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pyautogui/__init__.py", line 978, in click
    platformModule._multiClick(x, y, button, clicks)
  File "/usr/local/lib/python3.7/site-packages/pyautogui/_pyautogui_osx.py", line 516, in _multiClick
    core_graphics.CGEventPost(kCGEvent.Tap.value, mouseEvent)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/enum.py", line 349, in __getattr__
    raise AttributeError(name) from None
AttributeError: Tap

any ideas how to fix this?



Solution 1:[1]

I'm the creator of PyAutoGUI. This error happened for a few versions when we were changing the dependencies for macOS. This has been fixed in later versions of PyAutoGUI, so just run pip3 install -U pyautogui

Solution 2:[2]

Try This

import pyautogui

pyautogui.moveTo(500, 1100, duration=1)
pyautogui.click()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Al Sweigart
Solution 2 Maybe Lindow