Application that works in local but not online

Hi,
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 :

https://share.streamlit.io/mathg15/graphicinterfacemoosh/appStreamlit.py
https://github.com/mathg15/GraphicInterfaceMoosh

Traceback (most recent call last):
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/script_runner.py”, line 350, in _run_script
exec(code, module.dict)
File “/app/graphicinterfacemoosh/appStreamlit.py”, line 34, in
genmoosh()
File “/app/graphicinterfacemoosh/Pages/MooshGenPage.py”, line 17, in genmoosh
gen = mooshGen(strucSlider, pol)
File “/app/graphicinterfacemoosh/Main/MooshGen.py”, line 30, in init
self.mat1 = widget.selecBoxGen1()
File “/app/graphicinterfacemoosh/Tools/widget.py”, 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/selectbox.py”, line 121, in selectbox
current_value, set_frontend_value = register_widget(
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/state/widgets.py”, line 133, in register_widget
element_proto.id = 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 !

Hello,

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.

Best,
Randy

Thanks for the clarification.

Cheers.