TypeError: 'str' object is not callable

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)
1 Like

Hi @abhikpalli, welcome to the Streamlit forum!

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.

1 Like

Hey thanks for the input , updated the query in the requested format .

Hi @abhikpalli :wave:

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)

results in:

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. :confused:

How to create a Minimal, Reproducible Example

Hey ,

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.

Thanks

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}")

even a empty st.subheader() produces this error.

please shed some light over this problem

Your code works. Restart the application.

1 Like

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