Fixing ModuleNotFoundError: No module named 'tenacity._asyncio'

  1. Uninstall the current version of Tenacity:
    pip uninstall tenacity
    
  2. Install Tenacity version 5.1.5:
    pip install tenacity==5.1.5
    
  3. Locate the tenacity/_asyncio.py file:
    For example, on my machine, it was located at:
    C:\Users\[USER]\AppData\Local\Programs\Python\Python312\Lib\site-packages\tenacity\_asyncio.py
    
  4. Edit the function:
    I can't remember the exact function name, so I used my_function here. Replace:
    @asyncio.coroutine
    def my_function(...):
    
    with:
    async def my_function(...):
    
    This converts the two lines into one line.
  5. Replace yield from with await:
    Use ctrl-f to find yield from (it appears twice) and replace both occurrences with await.
Edit
Pub: 27 Jan 2025 07:17 UTC
Views: 731