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 tenacityVerified import paths — ran on the pinned version, not inferred.
A simple example demonstrating the use of Tenacity to retry a function that may raise an IOError.
Update code to use Tenacity's API.
Use 'from tenacity import retry' in your imports.
pip install tenacity
Add 'from tenacity import retry' at the top of your Python file.
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))'.
Replace 'max_attempts=N' with 'stop=stop_after_attempt(N)' to specify the desired maximum number of attempts.