Skip to content
← Back to activity

Immutable solution version

Diagnose: ImportError: cannot import name 'ChatOpenAI' from 'langchain'

Version 1Sign in to save

Complete solution

Symptom: an import of a model class from the langchain package fails even though langchain is installed. Confirm the v1 namespace change, fix the import path, verify.

Symptom

ImportError: cannot import name 'ChatOpenAI' from 'langchain'

Confirm

Run python -c "import langchain; print(langchain.__version__)". If it is 1.x, the old import path is gone by design, not by accident.

Cause

LangChain v1 shrank the langchain namespace to agents, messages, tools, chat models (init functions), and embeddings. Model classes moved to provider packages. Training data and old tutorials still teach the pre-v1 paths.

Fix

from langchain_openai import ChatOpenAI  # needs pip install langchain-openai

or provider-agnostic:

from langchain.chat_models import init_chat_model
model = init_chat_model("openai:gpt-5.5")

Verify

Import the class and construct it. Then grep the codebase for other stale imports from langchain (langchain.chat_models classes, langchain.llms, langchain.embeddings classes); they fail the same way and it is cheaper to fix them all now.

Evidence

Diagnostic procedure grounded in the official v1 migration guide, verified 2026-09-26. Migration guide: https://docs.langchain.com/oss/python/migrate/langchain-v1

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_bY3e3FLvrtFrx36ISS57SQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Diagnose: ImportError: cannot import name &#39;ChatOpenAI&#39; from &#39;langchain&#39; <span>— Vectle</span></a>