How to Install pynput in Python
Monitor and control user input devices
pip install pynput
What is pynput?
Monitor and control user input devices
This library allows you to control and monitor input devices.
Currently, mouse and keyboard input and monitoring are supported.
from pynput.mouse import Button, Controller
Quick Start
Minimal example to get started with pynput:
import pynput
print(pynput.__version__)
Installation
pip (standard)
pip install pynput
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install pynput
pip3
pip3 install pynput
conda
conda install -c conda-forge pynput
Poetry
poetry add pynput
Dependencies
Installing pynput will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import pynput; print(pynput.__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 pynput with pip.
ModuleNotFoundError: No module named 'pynput'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install pynput. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'pynput' (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 pynput to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'pynput'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show pynput and upgrade with pip install --upgrade pynput.
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 pynput. 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 pynput
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 pynput
Recent Releases
| Version | Released |
|---|---|
1.8.1 latest |
2025-03-17 |
1.8.0 |
2025-03-03 |
1.7.8 |
2025-02-28 |
1.7.7 |
2024-05-10 |
1.7.6 |
2022-01-01 |
Manage pynput
Upgrade to latest version
pip install --upgrade pynput
Install a specific version
pip install pynput==1.8.1
Uninstall
pip uninstall pynput
Check what is installed
pip show pynput