Selectbox Value has invalid type: NoneType

Getting Error Selectbox Value has invalid type: NoneType
When setting Index = None

The code works fine on the desktop, but when deploying it, This error comes up, How to solve it?

selection = st.selectbox('Transactions:',options=['Payments_Applications','Upload_File'],index=None,placeholder='Select an Option')

if selection == 'Payments_Applications':
        st.text('Generate Data Frame to work with by Selecting the Date Ranges you want to process')

 elif selection == 'Upload_File':
       
        col1,col2 = st.columns(2)

        with col1:
            file_uploaded = st.file_uploader('Upload Template file with payments and invoices details')
            

raise StreamlitAPIException(

streamlit.errors.StreamlitAPIException: Selectbox Value has invalid type: NoneType

Install a more recent streamlit.

selection = st.selectbox(‘Transactions:’, options=[‘Payments_Applications’, ‘Upload_File’], index=None, placeholder=‘Select an Option’)

if selection is not None:
if selection == ‘Payments_Applications’:
st.text(‘Generate Data Frame to work with by Selecting the Date Ranges you want to process’)
elif selection == ‘Upload_File’:
col1, col2 = st.columns(2)
with col1:
file_uploaded = st.file_uploader(‘Upload Template file with payments and invoices details’)
else:
st.warning(‘Please select an option.’)

You can use this code to avoid error

Hi @Sahil_Gupta. Here is the small suggestion that to use multiple comment type for attaching any code to the user. Where the user can easily copy the code. Like this:-

selection = st.selectbox('Transactions:', options=['Payments_Applications', 'Upload_File'], index=None, placeholder='Select an Option')

if selection is not None:
    if selection == 'Payments_Applications':
        st.text('Generate Data Frame to work with by Selecting the Date Ranges you want to process')
    elif selection == 'Upload_File':
        col1, col2 = st.columns(2)
        with col1:
            file_uploaded = st.file_uploader('Upload Template file with payments and invoices details')
else:
    st.warning('Please select an option.')

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