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

I’ve setup streamlit locally on my mac using:
python -m venv streamlit_env
source streamlit_env/bin/activate
pip install streamlit
pip install -r requirements.txt

where requirements.txt has:
mysqlclient
sqlalchemy==2.0.22

running pip list shows (among other modules)
mysqlclient 2.2.1
SQLAlchemy 2.0.22
streamlit 1.30.0

But yet when I run with the streamlit_env activated I still get this error:
ModuleNotFoundError: No module named ‘sqlalchemy’. You need to install the ‘sqlalchemy’ package to use this connection.

Any ideas on what I’m missing?
Thanks.

Hi @gmercer,

Thanks for posting!

Sometimes Python might not be looking in the right place for the installed modules. Check your Python path using the following code to verify while your venv is still activated:

python -c "import sys; print(sys.path)"

If you’re still running into errors, try running the app without the virtual environment to troubleshoot.

Thanks Tony.
Found out that even when I was in the streamlit_env it was picking up a streamlit from a bin outside of the streamlit_env. Once I got that straightened out then it was able to find the module.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

Glad it worked!
Happy Streamlit-ing! :balloon: