DuplicateWidgetID: There are multiple identical st.selectbox widgets with the same generated key

Hi @Glaxer :wave:

The error message gives you a hint about what is wrong. It is saying that when you don’t specify a unique key for each st.selectbox created in your for loop, all the selectbox widgets are assigned the same key because they have the same label. Multiple widgets of the same type cannot have the same key.

What you could do is assign a random key to each select box, or even simply do key=f"{name}", provided that entries in nom_catgs are unique. Try modifying the first line of your for loop to be:

for name in nom_catgs:
    option = st.selectbox(
        "Quel catégorie souhaitez-vous extraire ?", (nom_catgs), key=f"{name}"
    )
2 Likes