Modules not installed -- requirements.txt

Hi all,

I’m having trouble with the requirements needed for my app to run. I have a requirements.txt file in the root of my repo which contains the following. I need to use psycopg2 to connect to my database and followed Streamlits documentation on how to connect to PostgreSQL. I’m not having any issues with either pandas or numpy, but the application continuously returns

ModuleNotFoundError: No module named ‘sqlalchemy’. You need to install the ‘sqlalchemy’ package to use this connection.

Here is what my requirements.txt looks like. I do not know if I need anything more for it. or if with just having the text file in there should work.

streamlit
pandas
numpy
psycopg2-binary
sqlalchemy

To be honest, right now I’m not building the app locally but using Codespaces if that makes any change.

Thank you in advance

Hi @miguelcrespoCap

Have you tried pinning a specific version to see if that resolves the module not found error:

Yes! I have tried specifying the version for both psycopg2 and sqlalchemy but with no luck. I attached a picture below the comment where we can see directly in the Codespace how is the environment complaining about the modules directly from the requirements.txt

streamlit
pandas
numpy
psycopg2-binary==2.9.9
sqlalchemy==2.0.23

Please clarify, where does your streamlit app actually runs on?
On github codespace itself or on streamlit cloud?

The app runs except for the mentioned packages. If I remove any call for them it runs via CodeSpaces, it runs when locally and deployed as an app. It fails whenver I try to call

conn = st.connection(“postgresql”, type=“sql”)

Make sure your devcontainer.json actually installs the requirements.