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)

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