Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ModuleNotFoundError: No module named 'langchain.openai'

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading