Skip to content

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

@SebastianDT1

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.xit forces langchain-core>=1.4.0, breaking langchain 0.3.x, langgraph 0.3.x, and
langgraph-prebuilt.
2. Python 3.14 breaks the fallbacklangchain.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,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions