How to Install tenacity in Python
Retry code until it succeeds
pip install tenacity
What is tenacity?
Retry code until it succeeds
Tenacity is a general-purpose retrying library to simplify the task of adding retry behavior to just about anything.
Quick Start
Minimal example to get started with tenacity:
import tenacity
print(tenacity.__version__)
Installation
pip (standard)
pip install tenacity
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install tenacity
pip3
pip3 install tenacity
conda
conda install -c conda-forge tenacity
Poetry
poetry add tenacity
Verify the Installation
After installing, confirm the package is available:
python -c "import tenacity; print(tenacity.__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 tenacity with pip.
ModuleNotFoundError: No module named 'tenacity'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install tenacity. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'tenacity' (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 tenacity to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'tenacity'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show tenacity and upgrade with pip install --upgrade tenacity.
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 tenacity. 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 tenacity
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 tenacity
Recent Releases
| Version | Released |
|---|---|
9.1.4 latest |
2026-02-07 |
9.1.3 |
2026-02-05 |
9.1.2 |
2025-04-02 |
9.0.0 |
2024-07-29 |
8.5.0 |
2024-07-05 |
Manage tenacity
Upgrade to latest version
pip install --upgrade tenacity
Install a specific version
pip install tenacity==9.1.4
Uninstall
pip uninstall tenacity
Check what is installed
pip show tenacity