I am trying to add a weather widget in my streamlit app. I stored my API_KEY, longitude and latitude values in the secrets.toml file. My latitude value is a negative value, I used inverted commas for example lat = “-30.55445” in my secrets.toml file. It ran fine when I ran it on localhost for a while, now it doesn’t. It gives me this error: KeyError: 'st.secrets has no key “lat”. Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud? I really don’t know what I could be doing wrong, because my app is down now, because of this error.
I tried your suggestion, it ran fine on localhost. When I deployed it, I received this error:
Traceback (most recent call last):
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 565, in _run_script
exec(code, module.dict)
File “/app/lesson-planafr/app.py”, line 111, in
latitude = st.secrets.my_secrets.latitude
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/secrets.py”, line 296, in getattr
raise AttributeError(_missing_attr_error_message(key))
AttributeError: st.secrets has no attribute “my_secrets”. Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud? More info: Secrets management - Streamlit Docs
What part is expected behavior? I used these instructions you gave me to develop my code. Looking out for these expected errors. So, can you tell me what part was expected behavior?
It looks like I had to create a new repo and also a new app before it could deploy successfully.
My plan was to update my existing app with a new weather widget which contained an API key as everybody knows. Now adding a secrets.toml file and adding it to a .gitignore file doesn’t deploy your app successfully.
My suggestion is that the Streamlit developers should look into this, because as a result I had to create an entirely new app with a new link just to add a widget to my app, which isn’t ideal.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.