Tenacity
raw JSON → 9.1.4 verified Tue May 12 auth: no python install: verified quickstart: verified
Tenacity is a general-purpose retrying library for Python, designed to simplify adding retry behavior to functions. The current version is 9.1.4, released on February 7, 2026. It follows a regular release cadence, with recent updates addressing Python 3.14 support and improvements to retry annotations. ([pypi.org](https://pypi.org/project/tenacity/?utm_source=openai))
pip install tenacity Common errors
error ModuleNotFoundError: No module named 'tenacity' ↓
cause The 'tenacity' library has not been installed in the current Python environment.
fix
pip install tenacity
error NameError: name 'retry' is not defined ↓
cause The 'retry' decorator was used in the code without being imported from the 'tenacity' library.
fix
Add 'from tenacity import retry' at the top of your Python file.
error TypeError: 'int' object is not callable ↓
cause The 'wait' or 'stop' parameters of the 'retry' decorator were provided with a non-callable value like an integer, instead of a 'tenacity' helper function.
fix
Use tenacity helper functions such as 'wait_fixed(N)' or 'stop_after_attempt(N)' for the 'wait' and 'stop' parameters, e.g., '@retry(wait=wait_fixed(2))'.
error TypeError: retry() got an unexpected keyword argument 'max_attempts' ↓
cause The 'retry' decorator does not accept a direct 'max_attempts' argument; the maximum number of attempts is configured using the 'stop' parameter.
fix
Replace 'max_attempts=N' with 'stop=stop_after_attempt(N)' to specify the desired maximum number of attempts.
Warnings
breaking Tenacity is a fork of the 'retrying' library and is not API compatible with it. ↓
fix Update code to use Tenacity's API.
gotcha Ensure 'retry' is imported from 'tenacity' to utilize its retrying capabilities. ↓
fix Use 'from tenacity import retry' in your imports.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.05s 18.0M
3.10 slim (glibc) - - 0.04s 18M
3.11 alpine (musl) - - 0.12s 19.9M
3.11 slim (glibc) - - 0.09s 20M
3.12 alpine (musl) - - 0.10s 11.7M
3.12 slim (glibc) - - 0.10s 12M
3.13 alpine (musl) - - 0.12s 11.4M
3.13 slim (glibc) - - 0.10s 12M
3.9 alpine (musl) - - 0.05s 17.5M
3.9 slim (glibc) - - 0.06s 18M
Imports
- retry
from tenacity import retry
Quickstart verified last tested: 2026-04-23
import random
from tenacity import retry
@retry
def do_something_unreliable():
if random.randint(0, 10) > 1:
raise IOError('Broken sauce, everything is hosed!!!111one')
else:
return 'Awesome sauce!'
print(do_something_unreliable())