Vito Sorrentino
Vito Sorrentino

Reputation: 13

I installed a python package (langchain) using "pip install", but it can't be imported

I installed it globally using pip install langchain but I can't import it on my python code.

I am using PyCharm and VS Code, from langchain.llms import OpenAI. the package works well, I did on my work pc, but it doesn't work on my home pc.

I simply typed from langchain.llms import OpenAI and it says No module named 'langchain, I also checked using pip list, and it shows langchain, I even tried using the File Explorer to go to Python311/Lib/site-packages, it is there but I can't import it.

I also tried installing other packages, and it works well aside from langchain.

Upvotes: 1

Views: 9477

Answers (1)

ZKS
ZKS

Reputation: 2866

Could you try below steps.

Create a virtual environment using the command

python -m venv my_venv_name

Activate the virtual environment by executing source

 my_venv_name/bin/activate

PIP install libraries

pip install langchain
pip install """Other required libraries like OpenAI etc.

You should now successfully able to import

from langchain.llm import OpenAI

Lastly when executing the code, make sure you are pointing to correct interpreter (In Pycharm)

enter image description here

Upvotes: 3

Related Questions