St.multiselect and max_selections (int) - Solved

I want the user to be able to choose maximum 3 options out of a list through multiselect.
Code:
List = st.multiselect(‘Select 3 companies’, companies3[‘name’],3,key = “0123”, max_selections=3)
Error:
TypeError: multiselect() got an unexpected keyword argument ‘max_selections’

Screenshot 2022-11-10 at 7.23.00 AM

it seems from the above screenshot, that max_selection is not part of the code eventhough in the website they mention it

I used your code, substituting a range for the list of companies and removing the default selection of the number 3 and it ran fine for me. The first 3 you have in the line is being interpreted as the default selection (e.g. an item on your list that is selected), but I would expect that to throw a different error if it wasn’t compatible with your list of companies.

st.multiselect('Select 3 companies', range(10),key ='012', max_selections=3)

image

If you’re still getting the error, can you post more screen shots?

Hi @Nikos_Kyriakou ,

thanks for posting your question! Welcome :slight_smile:
Are you sure you’re on the latest streamlit?
If you want to check for that, you can check by running streamlit --version.
If you notice you’re not on the latest streamlit version, you can check out these docs to upgrade your streamlit.

thank you for your feedback, unfortunately the issue persist
@willhuang I reinstalled and I have the latest version the issue still persist
@mathcatsand I copy pasted your code and still get the below error

FYI not sure if this maybe the issue, I run in in Spyder through Anaconda

@Nikos_Kyriakou would you mind adding this line to your streamlit app before the multiselect?

st.write(st.__version__)

and let us know what version number it says?

Hi

It was a matter of version, I updated and now works.
It seems I was using the wrong code when updating streamlit in anaconda

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.