ImportError: cannot import name 'X' from 'langchain.chains', 'langchain.schema', 'langchain.chat_models' ...: which version has it, and where it is now
LangChain 1.0.0 (2025-10-17) removed 39 of its top-level modules, among them langchain.chains, langchain.schema, langchain.memory, langchain.llms and langchain.vectorstores; 0.3.30 is the last release with them. 38 of them live on under the same path in the separate package langchain-classic: pip install langchain-classic, then from langchain_classic.chains import LLMChain. Messages, documents and prompts are in langchain_core. Model classes such as ChatOpenAI are in the provider packages (langchain_openai). Many names under langchain.* in 0.1 to 0.3 were never defined there: they were forwarded to langchain_community and worked only with it installed. For any name, paste the error below.
Corrected on 2026-12-05: langchain-core was read only at the first release of each minor version, so a name added or removed in one of its patch releases was dated to the next minor. For example, from langchain_core.rate_limiters import InMemoryRateLimiter works from langchain-core 0.2.24 (2024-07-26), not only from 0.3.0. Every langchain-core release was then read once from PyPI: 8 top-level names and 2,363 module-and-name pairs in all differ in some patch release from the first release of the same minor. The lookup now gives those patch releases. langchain and langchain-classic were already read at every release.
Examples:
Runs in your browser on langchain.json (604 KB), langchain_classic.json (588 KB) and langchain_core.json (497 KB), loaded as needed; nothing you paste is sent anywhere. Covers 35,388 module-and-name pairs.
The imports people hit, and the import that works now
All of these work in langchain 0.1.0 to 0.3.30 and fail from 1.0.0.
| Old import | In 0.1 to 0.3 | Now |
|---|---|---|
from langchain.chains import LLMChain | defined in langchain | from langchain_classic.chains import LLMChain (pip install langchain-classic) |
from langchain.chains import RetrievalQA | defined in langchain | from langchain_classic.chains import RetrievalQA (pip install langchain-classic) |
from langchain.chains import ConversationalRetrievalChain | defined in langchain | from langchain_classic.chains import ConversationalRetrievalChain (pip install langchain-classic) |
from langchain.memory import ConversationBufferMemory | defined in langchain | from langchain_classic.memory import ConversationBufferMemory (pip install langchain-classic) |
from langchain.agents import AgentExecutor | defined in langchain | from langchain_classic.agents import AgentExecutor; new code: langchain.agents.create_agent |
from langchain.agents import initialize_agent | defined in langchain | from langchain_classic.agents import initialize_agent; new code: langchain.agents.create_agent |
from langchain.text_splitter import RecursiveCharacterTextSplitter | defined in langchain | from langchain_text_splitters import RecursiveCharacterTextSplitter (pip install langchain-text-splitters) |
from langchain.schema import HumanMessage | defined in langchain | from langchain_core.messages import HumanMessage, or from langchain.messages import HumanMessage (1.0.0 on) |
from langchain.schema import Document | defined in langchain | from langchain_core.documents import Document |
from langchain.prompts import PromptTemplate | defined in langchain | from langchain_core.prompts import PromptTemplate |
from langchain.chat_models import ChatOpenAI | forwarded to langchain_community.chat_models | from langchain_openai import ChatOpenAI |
from langchain.vectorstores import FAISS | forwarded to langchain_community.vectorstores | from langchain_community.vectorstores import FAISS (pip install langchain-community) |
from langchain.document_loaders import PyPDFLoader | forwarded to langchain_community.document_loaders | from langchain_community.document_loaders import PyPDFLoader (pip install langchain-community) |
from langchain.embeddings import OpenAIEmbeddings | forwarded to langchain_community.embeddings | from langchain_openai import OpenAIEmbeddings |
Which modules did LangChain 1.0 remove?
39 top-level modules; the right column is where the same module lives from 1.0.0. What stayed in langchain is small: agents (with create_agent), chat_models (init_chat_model), embeddings, messages, tools and a few more.
| Removed in 1.0.0 | Same module now |
|---|---|
langchain._api | langchain_classic._api |
langchain.adapters | langchain_classic.adapters |
langchain.base_language | langchain_classic.base_language |
langchain.cache | langchain_classic.cache |
langchain.callbacks | langchain_classic.callbacks |
langchain.chains | langchain_classic.chains |
langchain.chat_loaders | langchain_classic.chat_loaders |
langchain.docstore | langchain_classic.docstore |
langchain.document_loaders | langchain_classic.document_loaders |
langchain.document_transformers | langchain_classic.document_transformers |
langchain.env | langchain_classic.env |
langchain.evaluation | langchain_classic.evaluation |
langchain.example_generator | langchain_classic.example_generator |
langchain.formatting | langchain_classic.formatting |
langchain.globals | langchain_classic.globals |
langchain.graphs | langchain_classic.graphs |
langchain.hub | langchain_classic.hub |
langchain.indexes | langchain_classic.indexes |
langchain.input | langchain_classic.input |
langchain.llms | langchain_classic.llms |
langchain.load | langchain_classic.load |
langchain.memory | langchain_classic.memory |
langchain.model_laboratory | langchain_classic.model_laboratory |
langchain.output_parsers | langchain_classic.output_parsers |
langchain.prompts | langchain_classic.prompts |
langchain.pydantic_v1 | none: use pydantic directly |
langchain.python | langchain_classic.python |
langchain.requests | langchain_classic.requests |
langchain.retrievers | langchain_classic.retrievers |
langchain.runnables | langchain_classic.runnables |
langchain.schema | langchain_classic.schema |
langchain.serpapi | langchain_classic.serpapi |
langchain.smith | langchain_classic.smith |
langchain.sql_database | langchain_classic.sql_database |
langchain.storage | langchain_classic.storage |
langchain.text_splitter | langchain_classic.text_splitter |
langchain.utilities | langchain_classic.utilities |
langchain.utils | langchain_classic.utils |
langchain.vectorstores | langchain_classic.vectorstores |
Why did some imports work only with langchain-community installed?
In 0.1 to 0.3, modules such as langchain.chat_models, langchain.llms, langchain.vectorstores and langchain.document_loaders forwarded 1,243 names to langchain_community through a module-level __getattr__, with a deprecation warning. Without langchain-community the same line raised ImportError, on any version. langchain_classic keeps that forwarding. The lookup marks each forwarded name and gives the langchain_community module to import from directly.
How was this read, and how was it checked?
From the source of each release tag of the langchain monorepo, with Python's ast module; no release was installed or imported. langchain 0.x is read from libs/langchain, 1.x from libs/langchain_v1, langchain-classic from libs/langchain/langchain_classic, langchain-core from libs/core. A module's names are everything it binds at module level, plus the names its __getattr__ serves: the strings of __all__ and the keys of its lookup tables (DEPRECATED_LOOKUP, _dynamic_imports, create_importer(...)). Dates come from PyPI.
Checks, by a second reading: (1) each top-level name is found as plain text in __init__.py in every release of its range (8,586 name-and-release pairs). (2) A regular expression finds 29,928 definitions in 7,163 file versions; all are among the names read. (3) Regular expressions over every module that defines __getattr__ find 161,854 served names (summed over releases); all are among the names read. (4) 17 known facts hold, among them the reports under Sources.
Limits
- Nothing was installed or run. "Has it" means the import resolves in the source, with langchain-community installed for forwarded names.
- langchain 0.0.x is not read; "0.1.0 or earlier" means the name was there in the first release read. langchain-core is read from 0.1.47 (its first git tag), at the first release of each minor; every later release was also read once (224 releases, from the wheels on PyPI, with the same rules), and the lookup prints the patch releases that differ under the range.
- langchain_community and the provider packages (langchain_openai, ...) are not read; the lookup names them only where langchain itself points to them.
- A forwarded name is taken from
__all__; in 0.1 the forwarding passed along any name of the target module, so a few more names worked.
Questions
How do I fix "cannot import name 'LLMChain' from 'langchain.chains'"?
LangChain 1.0.0 (2025-10-17) removed langchain.chains; 0.3.30 is the last release with it. Install the package that keeps the old code: pip install langchain-classic, then from langchain_classic.chains import LLMChain. Or pin pip install "langchain<1.0.0".
Where did langchain.schema, langchain.memory and langchain.agents.AgentExecutor go?
To langchain-classic: 38 of the 39 top-level modules that LangChain 1.0 removed exist under the same path in langchain_classic. Messages, documents and prompts are also in langchain_core (langchain_core.messages, langchain_core.documents, langchain_core.prompts). For agents, LangChain 1.0 has langchain.agents.create_agent.
Why did "from langchain.chat_models import ChatOpenAI" work in 0.3 but not in 1.0?
In 0.1 to 0.3, langchain.chat_models did not define ChatOpenAI; it forwarded the name to langchain_community.chat_models with a deprecation warning, and only when langchain-community was installed. 1.0 dropped the forwarding. Use from langchain_openai import ChatOpenAI.
I installed langchain-classic and "from langchain_classic.document_loaders import PyPDFLoader" still fails. Why?
langchain_classic forwards document loaders, vector stores and other integrations to langchain_community, like langchain 0.3 did. Install langchain-community, or import from langchain_community.document_loaders directly.
What did langchain-core 1.0 remove?
The modules langchain_core.beta, langchain_core.graph_vectorstores, langchain_core.memory, langchain_core.pydantic_v1. Memory classes live in langchain_classic.memory; for pydantic_v1, import from pydantic directly.
Sources
- langchain-ai/langchain, release tags
v0.1.x,langchain==,langchain-classic==andlangchain-core==: every.pyfile of the package at each tag; for example langchain/chat_models/__init__.py at 0.3.30 (the forwarding) and langchain_openai/__init__.py. Release dates from PyPI. - Reports: langchain.chains and langchain.prompts after v1, PyPDFLoader from langchain_classic.document_loaders, content from langchain_core.messages.
The same data as JSON: langchain.json, langchain_classic.json, langchain_core.json, licensed CC BY 4.0.
Related: "cannot import name ... from 'transformers'" · "... from 'huggingface_hub'" · "... from 'sentence_transformers'".