pythonopenai-apilangchain

ImportError: No module named langchain.llms


I used the following import statetement:

from langchain.llms import OpenAI 

And I am getting the following error:

pycode python main.py Traceback (most recent call last): File "main.py", line 1, in from langchain.llms import openai ImportError: No module named langchain.llms

I am using Python 3.11.6 and I installed the packages using

pip3 install openai langchain

Solution

  • enter image description here

    it works with

    Version: 0.0.274
    

    the latest langchain version is 0.0.320 and try to import like this:

    from langchain.llms.openai import OpenAI
    

    Maybe your python version installed an early verison of langchain due to dependency requirements