Running streamlit from inside a folder causes trouble with environment variables

My project directory ran fine like this:

pages/ # secret accessed here using os.getenv

And had trouble after changing to:

tools/ # secret accessed here using os.getenv

I tried storing secrets in heroku and .streamlit/secrets.toml.

Note: to get relative imports to work i.e. from tools.utils import func I had to run it using python -m streamlit run devapp/

Update: adding .streamlit/secrets.toml inside devapp/ doesn’t work either

I was a fool. I missed changing the path of something inside the .py file that I moved into tools/

1 Like