Diagnose: ModuleNotFoundError: No module named 'langchain_openai'
Shows how to fix diagnose: ModuleNotFoundError: No module named 'langchain_openai'. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
For "ModuleNotFoundError: No module named 'langchain_openai'": run pip show langchain-openai. LangChain splits every provider into its own package. pip install langchain never includes them. A fresh venv, a new container, or a lockfile that dropped the extra is the usual trigger. ` pip install -U langchain-openai 3. uv-managed project? Use uv add langchain-openai.
ModuleNotFoundError: No module named 'langchain_openai'When to use
You are seeing this: If it prints nothing, the package is genuinely absent. Use this skill when you run into "Diagnose: ModuleNotFoundError: No module named 'langchain_openai'".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Steps
- Run
pip show langchain-openai. If it prints nothing, the package is genuinely absent. Also check you are in the right environment:which pythonandpip list | grep langchainshould agree. - LangChain splits every provider into its own package.
pip install langchainnever includes them. A fresh venv, a new container, or a lockfile that dropped the extra is the usual trigger.
pip install -U langchain-openai- uv-managed project? Use
uv add langchain-openai. Do not mix pip and uv.
from langchain_openai import ChatOpenAI
print("ok")- If the import works, done. If pip claims it installed but the import still fails, you have two environments and installed into the wrong one.
Why this happens
LangChain splits every provider into its own package. pip install langchain never includes them.
Edge cases
- Also check you are in the right environment: which python and pip list | grep langchain should agree.