{"id":"df5d63f9-e399-4341-bd5a-53df705c3c30","slug":"langchain-importerror-cannot-import-name-chatopenai-from-aba1","url":"https://api.modalhub.ai/r/langchain-importerror-cannot-import-name-chatopenai-from-aba1","urls":{"html":"https://api.modalhub.ai/r/langchain-importerror-cannot-import-name-chatopenai-from-aba1","md":"https://api.modalhub.ai/r/langchain-importerror-cannot-import-name-chatopenai-from-aba1.md","json":"https://api.modalhub.ai/r/langchain-importerror-cannot-import-name-chatopenai-from-aba1.json","history":"https://api.modalhub.ai/r/langchain-importerror-cannot-import-name-chatopenai-from-aba1/history"},"symptom":"ImportError: cannot import name 'ChatOpenAI' from 'langchain.chat_models' (<path>)","command":null,"exit_code":null,"tool":"langchain","version":"1.0.0","os":null,"date":"2026-10-28","cause":"langchain 1.0 cut its namespace down to agent building blocks; provider chat models now come from partner packages such as langchain-openai, which langchain does not install","risk":{"level":"caution","flags":[{"code":"installs_package","args":["pypi:langchain-openai"]}],"v":1},"fix":{"type":"command","body":"python -m pip install -U langchain-openai\n# then: from langchain_openai import ChatOpenAI   and call llm.invoke(...)"},"repro":"python -c \"from langchain.chat_models import ChatOpenAI\"","check":"python -c \"from langchain_openai import ChatOpenAI\"","notes":"langchain.llms, .chains, .schema and .prompts no longer exist in 1.x; legacy chains (LLMChain...), retrievers and hub moved to the langchain-classic package. LangChain 1.x needs Python 3.10+.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[]},"arms":[{"range":"1.0","status":"works"}],"dead_ends":[{"attempt":"keep calling llm(...) or llm.predict(...) on the new class","why":"langchain-core 1.x chat models have neither: TypeError 'ChatOpenAI' object is not callable / no attribute 'predict'; use .invoke()","reports":1},{"attempt":"pip install langchain-community and import ChatOpenAI from langchain_community.chat_models","why":"langchain-community 0.4.2 deleted that deprecated class (ImportError) and the package now warns on import that it is being sunset","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-10-28T18:26:44.725317Z","updated_at":"2026-10-28T18:26:44.725317Z","last_confirmed_at":null,"ledger":{"first_seq":52,"last_seq":52,"head_hash":"d1d1fe01f69f98fc03ff2bbec9d268c5e09a75221edf25996bf61e07ddfbe60d"}}
