Application that works in local but not online

I’ve got some issues with my app. Some widgets didn’t work online but work locally.
When i use them online, i’ve got this :

Traceback (most recent call last):
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/”, line 350, in _run_script
exec(code, module.dict)
File “/app/graphicinterfacemoosh/”, line 34, in
File “/app/graphicinterfacemoosh/Pages/”, line 17, in genmoosh
gen = mooshGen(strucSlider, pol)
File “/app/graphicinterfacemoosh/Main/”, line 30, in init
self.mat1 = widget.selecBoxGen1()
File “/app/graphicinterfacemoosh/Tools/”, line 43, in selecBoxGen1
return st.selectbox(“Choix du matériau 1”, (“Air”, “Eau”, “Bk7”, “SiO2”, “TiO2”, “Au”, “Cr”,“Ag”,“ZnO”), key=1)
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/elements/”, line 121, in selectbox
current_value, set_frontend_value = register_widget(
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/state/”, line 133, in register_widget = widget_id
TypeError: 1 has type int, but expected one of: bytes, unicode

It seems like key does not accept int.
The problem is that the application works in local and it was working 1 month ago.
How can i fix this ?
Thanks !


The last time I had this issue, I found out that in Streamlit v0.86.0, st.selectbox() requires the key to be a string. Try key=str(1) and see if that works.

In a case (as mine) where you’re incrementing the widget keys, you’ll need something like key=f"{widget_key}", where widget_key is a integer variable you increment every time the script runs.

Yes, this is an unfortunate bug that made it into the library. My understanding is that we will be correcting it shortly to allow integer keys again instead of requiring strings. Until then, doing an f-string is a good solution.


Thanks for the clarification.