I’m using Python 3.8.I have installed langchain using pip install Langchain. But I’m getting error ModuleNotFoundError: No module named 'langchain.openai' while running from langchain.openai import ChatOpenAI. import langchain is working in my python. Can you suggest me steps to resolve this issue?
>Solution :
Installation
I believe you need to do
pip install langchain-openai
according to LangChain and PyPI.
Initialization
Furthermore, the model should be initialized as
from langchain_openai import ChatOpenAI
llm = ChatOpenAI()
as stated in the quickstart.
Note that its _ instead of . between "langchain" and "openai" in the import statement.
Credits to @Thierry Lathuille for pointing this out in the comments.