How to Install PyAutoGUI in Python
PyAutoGUI lets Python control the mouse and keyboard, and other GUI automation tasks. For Windows, macOS, and Linux, on Python 3 and 2.
pip install PyAutoGUI
What is PyAutoGUI?
PyAutoGUI lets Python control the mouse and keyboard, and other GUI automation tasks. For Windows, macOS, and Linux, on Python 3 and 2.
PyAutoGUI is a cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard. Full documentation available at Simplified Chinese documentation available at Source code available at If you need help installing Python, visit Dependencies
PyAutoGUI supports Python 2 and 3. If you are installing PyAutoGUI from PyPI using pip: Windows has no dependencies. The Win32 extensions do not need to be installed. macOS needs the pyobjc-core and pyobjc module installed (in that order). Linux needs the python3-xlib (or python-xlib for Python 2) module installed. Pillow needs to be installed, and on Linux you may need to install additional libraries to make sure Pillow's PNG/JPEG works correctly. See: If you want to do development and contribute to PyAutoGUI, you will need to install these modules from PyPI: pyscreeze pymsgbox pytweening Example Usage
The x, y coordinates used by PyAutoGUI has the 0, 0 origin coordinates in the top left corner of the screen. The x coordinates increase going to the right (just as in mathematics) but the y coordinates increase going down (the opposite of mathematics). On a screen that is 1920 x 1080 pixels in size, coordinates 0, 0 are for the top left while 1919, 1079 is for the bottom right. Currently, PyAutoGUI only works on the primary monitor. PyAutoGUI isn't reliable for the screen of a second monitor (the mouse functions may or may not work on multi-monitor setups depending on your operating system and version). All keyboard presses done by PyAutoGUI are sent to the window that currently has focus, as if you had pressed the physical keyboard key. Display Message Boxes
Quick Start
Minimal example to get started with PyAutoGUI:
import pyautogui
print(pyautogui.__version__)
Installation
pip (standard)
pip install PyAutoGUI
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install PyAutoGUI
pip3
pip3 install PyAutoGUI
conda
conda install -c conda-forge PyAutoGUI
Poetry
poetry add PyAutoGUI
Verify the Installation
After installing, confirm the package is available:
python -c "import pyautogui; print(pyautogui.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing PyAutoGUI with pip.
ModuleNotFoundError: No module named 'pyautogui'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install PyAutoGUI. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'pyautogui' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install PyAutoGUI to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'pyautogui'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show PyAutoGUI and upgrade with pip install --upgrade PyAutoGUI.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install PyAutoGUI. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user PyAutoGUI
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org PyAutoGUI
Recent Releases
| Version | Released |
|---|---|
0.9.54 latest |
2023-05-24 |
0.9.53 |
2021-07-07 |
0.9.52 |
2020-10-06 |
0.9.51 |
2020-10-04 |
0.9.50 |
2020-04-01 |
Manage PyAutoGUI
Upgrade to latest version
pip install --upgrade PyAutoGUI
Install a specific version
pip install PyAutoGUI==0.9.54
Uninstall
pip uninstall PyAutoGUI
Check what is installed
pip show PyAutoGUI