Skip to content

Bug: LangchainIntegration crashes on Python 3.14 — ModuleNotFoundError: No module named 'langchain_classic' #6265

Closed

Description

@SebastianDT1

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.60.0

Steps to Reproduce

Bug: LangchainIntegration crashes on Python 3.14 — ModuleNotFoundError: No module named 'langchain_classic'

Environment

  • sentry-sdk: 2.57.0 (reproduced through 2.60.0)
  • Python: 3.14.3 (python:3.14-slim-bookworm)
  • langchain: 0.3.25 / langchain-core: 0.3.75
  • Introduced by: feat(langchain): Support v1 #4874 (feat(langchain): Support v1, merged Oct 23 2025)

Steps to Reproduce

  1. Use Python 3.14
  2. Install sentry-sdk==2.60.0 + langchain==0.3.25
  3. Call sentry_sdk.init() with any integration that auto-enables LangchainIntegration
  4. Start gunicorn workers

Expected Result

LangchainIntegration degrades gracefully — AgentExecutor falls back to None and the application starts normally.

Actual Result

Worker process crashes at startup with:

ModuleNotFoundError: No module named 'langchain_classic'
from langchain_classic.agents import AgentExecutor
File ".../sentry_sdk/integrations/langchain.py", line 60, in
File ".../gunicorn/arbiter.py", line 608, in spawn_worker

error [ERROR] Exception in worker process

Root cause — two problems in langchain.py lines 58–66:

try:
    from langchain_classic.agents import AgentExecutor  # >=v1
except ImportError:
    try:
        from langchain.agents import AgentExecutor      # <v1
    except ImportError:
        AgentExecutor = None

1. langchain-classic is uninstallable with langchain 0.3.x — it forces langchain-core>=1.4.0, breaking langchain 0.3.x, langgraph 0.3.x, and
langgraph-prebuilt.
2. Python 3.14 breaks the fallback — langchain.agents uses __getattr__-based lazy loading. On Python 3.14 the fallback raises an exception not
caught by except ImportError, propagating the crash.

Workaround:
sentry_sdk.init(
    dsn="...",
    integrations=[DjangoIntegration())],
    auto_enabling_integrations=False,
)

Activity

  1. linear-code commented on May 13, 2026

    @linear-code
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on May 13, 2026
  3. ericapisani commented on May 14, 2026

    @ericapisani
    Member

    @SebastianDT1 Thanks for opening an issue with us, I've added this to the team's backlog and someone will take a look.

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on May 14, 2026
  5. alexander-alderman-webb commented on May 15, 2026

    @alexander-alderman-webb
    Collaborator

    Problem occurs when execute the class Chain statement of the langchain.chains.base.Chain class.
    The langchain.agents module we load also imports the class.
    A related bug report is pydantic/pydantic#13036

    Here's the Dockerfile to repro (assumes you have a repro.py, ideally with some LangChain imports):

    FROM python:3.14.3-slim-bookworm
    
    RUN apt-get update \
     && apt-get install -y --no-install-recommends \
            gcc \
            libffi-dev \
            python3-dev \
     && rm -rf /var/lib/apt/lists/*
    
    WORKDIR /repro
    
    RUN pip install --no-cache-dir \
            "sentry-sdk==2.60.0" \
            "langchain==0.3.25" \
            "langchain-core==0.3.75"
    
    COPY repro.py .
    CMD ["python", "repro.py"]
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions