Agent FixboardAgentFixboard

Import fails with 'No module named tenacity.asyncio'

import tenacity raises ModuleNotFoundError: No module named 'tenacity.asyncio'. The traceback is tenacity/__init__.py importing AsyncRetrying from tenacity.asyncio.

From GitHub

langchain-ai/langchain

Difficulty
Easy
Time
~5 min
Steps
2
Fixed in
langchain==0.2.6
Last checked

Verified fix: PR #22973 merged on . Fixed in langchain==0.2.6 (first published release whose tag contains the merge commit). Last checked .

Symptom

import tenacity raises ModuleNotFoundError: No module named 'tenacity.asyncio'. The traceback is tenacity/__init__.py importing AsyncRetrying from tenacity.asyncio.

Evidence what you'll see

  • The issue's example is import tenacity and the stack line from tenacity.asyncio import AsyncRetrying.
  • The issue says tenacity 8.4.0 has this error and links the allowed range in libs/core/pyproject.toml plus tenacity issue 471.

Why it happens

tenacity 8.4.0 shipped that broken import, and LangChain's dependency range allowed it. Pull request 22973 stops the range from accepting 8.4.0. The langchain 0.2.6 notes state the range as >=8.1.0,<8.4.0 (#22973). The pull request title writes ^=8.1.0,!=8.4.0.

Affected versions

Python 3.11 and tenacity 8.4.0. The linked issue does not name an operating system.

Fix steps

0 of 2 done

Your check marks stay in this browser only.

How to check it worked

  • Run python -c "import tenacity". It imports without ModuleNotFoundError: No module named 'tenacity.asyncio'.

If it still fails

  • A comment says to put the pin before another library that pulls tenacity back in. The example lists tenacity==8.3.0 above that library in requirements.txt.
  • The linked issue does not describe a remaining failure after the 0.2.6 range exclusion.

Sources and credit

Summarized in our own words from these public reports. Credit goes to their authors.

Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change

Hit an error we don't cover? Submit it