When I write code in VS Code, beginning with:
import os
from langchain.chains import RetrievalQA
from langchain.llms import OpenAI
from langchain.document_loaders import TextLoader
I am met with the error: ModuleNotFoundError: No module named 'langchain'
I have updated my Python to version 3.11.4, have updated pip, and reinstalled langchain. I have also checked sys.path and the folder C:\\Python311\\Lib\\site-packages in which the Langchain folder is, is appended.
EDIT: Langchain import works when I run it in the Python console (functionality works too), but when I run the code from the VSCode run button it still provides the ModuleNotFoundError.
Has anyone else run into this issue and found a solution?
I had installed packages with python 3.9.7 but this version was causing issues so I switched to Python 3.10. When I installed the langhcain it was in python 3.9.7 directory. If yo run pip show langchain, you get this
Name: langchain
Version: 0.0.220
Summary: Building applications with LLMs through composability
Home-page: https://www.github.com/hwchase17/langchain
Author:
Author-email:
License: MIT
Location: /home/anaconda3/lib/python3.9/site-packages
Requires: aiohttp, async-timeout, dataclasses-json, langchainplus-sdk, numexpr, numpy, openapi-schema-pydantic, pydantic, PyYAML, requests, SQLAlchemy, tenacity
Required-by: jupyter_ai, jupyter_ai_magics
If you look at the Location property, you see this /home/anaconda3/lib/python3.9/site-packages. But since I am using Pyhton3.10 I had to make sure langchain is in the directory of Python 3.10. so installed the langhchain with
python3.10 -m pip install langchain
now when I run, python3.10 -m pip show langchain I get this
Name: langchain
Version: 0.0.264
Summary: Building applications with LLMs through composability
Home-page: https://www.github.com/hwchase17/langchain
Author:
Author-email:
License: MIT
Location: /home/.local/lib/python3.10/site-packages
Requires: aiohttp, async-timeout, dataclasses-json, langsmith, numexpr, numpy, openapi-schema-pydantic, pydantic, PyYAML, requests, SQLAlchemy, tenacity
Required-by:
Now new Location is referring to Python3.10 directory
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