Running into this error while trying to run a basic tutorial script for langchain:
ModuleNotFoundError: No module named 'langchain.llms'; 'langchain' is not a package
Here is the code snippet:
from langchain.llms import OpenAI
llm = OpenAI(temperature=0.9)
text = "What is a popular recipe using coconut milk?"
print(llm(text))
The issue was that one of my project files was named langchain.py. Renaming the file fixed this issue, otherwise it was importing the file instead of the actual library.
Found the answer here originally: https://github.com/hwchase17/langchain/issues/2079
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With