Hi All, Facing the following error : TypeError: ‘str’ object is not callable
in all the following below codes , what id the issue here .
#code sample 1 :
import streamlit as st
with st.form(key='my_form_to_submit'):
user = st.text_input("Enter some value here ")
submit_button = st.form_submit_button(label='Submit')
st.write(user)
#code sample 2 :
import streamlit as st
with st.form(key='my_form_to_submit'):
user1 = st.text_input("Enter some value here ")
submit_button = st.form_submit_button(label='Submit')
st.write(user1)
if submit_button:
st.write(user1)
#code sample 3 :
import streamlit as st
result=st.text_input("Enter some value here ")
if st.button('asas'):
st.write('Hello')
st.write(result)
Please check out our new guidelines for posting in the forum and update your post to include a properly formatted code snippet so we can reproduce the issue you’re seeing.
Unfortunately, the code sample you’ve provided does not reproduce the error you’ve described.
Running the following:
# code sample 1 :
import streamlit as st
with st.form(key="my_form_to_submit"):
user = st.text_input("Enter some value here ")
submit_button = st.form_submit_button(label="Submit")
st.write(user)
# code sample 2 :
import streamlit as st
with st.form(key="my_form_to_submit"):
user1 = st.text_input("Enter some value here ")
submit_button = st.form_submit_button(label="Submit")
st.write(user1)
if submit_button:
st.write(user1)
# code sample 3 :
import streamlit as st
result = st.text_input("Enter some value here ")
if st.button("asas"):
st.write("Hello")
st.write(result)
2022-09-28 15:14:23.340 Uncaught app exception
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 562, in _run_script
exec(code, module.__dict__)
File "/Users/skekre/Downloads/streamlit-misc/string-error.py", line 12, in <module>
with st.form(key="my_form_to_submit"):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/streamlit/runtime/metrics_util.py", line 231, in wrap
result = callable(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/streamlit/elements/form.py", line 190, in form
raise StreamlitAPIException(_build_duplicate_form_message(key))
streamlit.errors.StreamlitAPIException: There are multiple identical forms with `key='my_form_to_submit'`.
To fix this, please make sure that the `key` argument is unique for
each `st.form` you create.
Running the samples individually also doesn’t result in the TypeError: ‘str’ object is not callable.
it is working fine in my windows system , but this error was observed in Linux server. Anyways for now i have run the code in my local windows system and there are no errors.
Actually there is no solution and I am facing the same error with a very simple code.
running on Ubuntu Linux 22.04.2 LTS an IDE PyCharm with (venv Python 3.10).
import streamlit as st
st.title("Weather Forecast for the Next Days")
place = st.text_input("Place:")
days = st.slider("Forecast days", min_value=1, max_value=5,
help="Select the number of forecasted days")
option = st.selectbox("Select data to view", options=("temperature", "sky"))
st.subheader(f"Give {option} for the next {days} days in {place}")
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.