Having an Issue While Using Streamlit with Langchain Community

When I go to deploy my streamlit app I get this error: ModuleNotFoundError: No module named ‘langchain_community’
python3 -m venv env

But langchain community is installed, I’ve tested many times.

Please share the requirements.txt file you’ve used to configure your deployed environment, or share a link to your repository.

langchain_community is not installed in the environment in which your app is running.

streamlit==1.32.1

langchain-community==0.0.28

langchain-openai==0.0.8

langchain==0.1.11

faiss==1.8.0

Yes it is

The interpreter begs to differ. It doesn’t happen often that a human knows better, but it is not unheard of either. There is a cryptic reference to a virtual environment in the OP, but the error message shows that the application is not running in a virtual envirnment. What is the virtual environment for, then?

Can you share details on how you install the package, how do you test that it is installed, and how do you launch your application?

To be fair I am newer to coding so there is a high probability that I’m wrong about what I said earlier.
Not exactly sure how to tell what’s running in my virtual environment or how to make sure it’s setup properly. In the pic attached I just said “pip list” in my VSCode terminal.

Don’t want to take up too much of your time, just a point in the right direction is all and I can figure out the rest from there.

Thanks

Screenshot 2024-03-13 at 6.01.30 PM

So how are you running the application?

Does typing this in the same terminal work?

streamlit run app.py

yes, that is what brought me to the local webpage with the error.

This is the result. Also I may be incorrect, but I don’t think VSCode would let me use the langchain community packages in my code if it was installed incorrectly? Please critique me wherever I’m wrong. Happy to learn :slight_smile:

I don’t know VSCode and I am a bit puzzled because I don’t see the terminal in the screenshot. Anyway, for whatever reason, the application is not running in the same environment as pip was

How about this? Again, in the same terminal where you run pip and it shows that langchain-community is instaled`.

python -m streamlit run app.py

I had a similar issue because the version of streamlit was serving from outside of the venv.
Try doing: ~/path_to_your_venv/bin/streamlit run your_app.py

1 Like

This fixed it for me

Maybe the default python you are running for installation is in a wrong directory.
First move on to the directory you want to install the library and then, type:
./python -m pip install langchain-community
This will force the terminal to run the python program in that directory and install the library to that python.