I am trying to test the default code for forms, and there is appearing the message: AttributeError: module ‘streamlit’ has no attribute ‘form’.
Below is the code (from Streamlit website).
with st.form("my_form"):
st.write("Inside the form")
slider_val = st.slider("Form slider")
checkbox_val = st.checkbox("Form checkbox")
# Every form must have a submit button.
submitted = st.form_submit_button("Submit")
if submitted:
st.write("slider", slider_val, "checkbox", checkbox_val)
st.write("Outside the form")
Hi @Renan_Lopes, welcome to the Streamlit community!!
What version of the Streamlit library are you using? You can find out by including the following line above your st.form block:
st.write("Streamlit version:", st.__version__)
Or by running the following in your terminal:
streamlit version show
We releasedst.form and st.form_submit_button in Streamlit v0.81.1 in April 2021. If printing the version above confirms you’re running an older version, I highly recommend upgrading to the latest version to use all the cool features we’ve released since then.