Why do I get a key not initialized error when using data_editor with key set to "feeds"


Why do I get a key not initialized error when using data_editor with key set to “feeds”. No example of using a key value requires initialization prior to use.

Steps to reproduce

Code snippet:

if st.session_state['SELECTED_SITE_FEEDS_DATA']:
    st.data_editor(st.session_state.save_feeds_data,use_container_width = True,num_rows = "dynamic",column_config={
        "delete?": st.column_config.CheckboxColumn(
            help="Check to Remove This Feed",
        )},on_change =callback(),key="feeds_data")
    st.write("You must select a site before editing feeds")

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

I expect the key to be created in the sessions dictionary with current data.

Actual behavior:

Error Message: AttributeError: st.session_state has no attribute “feeds_data”

Debug info

  • Streamlit version: (get it with $ streamlit version) 1.27
  • Python version: (get it with $ python --version) 3.10
  • Using Conda? PipEnv? PyEnv? Pex? Conda
  • OS version: Mac OS Monterey
  • Browser version: Latest chrome

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.


  • Link to your GitHub repo:
  • Link to your deployed app:

Additional information

If needed, add any other context about the problem here.

Hey @steelliberty,

It sounds like you haven’t initialized that session state value – check out our doc on initializing session state here.

if 'key' not in st.session_state:
    st.session_state['key'] = 'value'

Hey thank you Caroline - but as I read the docs that should only be necessary if i am creating my own session variable like the one in my code st.session_state[‘SELECTED_SITE_FEEDS_DATA’]. - I watched the session state video and for widgets creating a key (key=‘key’) should be sufficient to create its own entry – the code behind that would and should do just what you did – I was curious as to why that is not the case for data_editor widget – Thank you - again.

The key in your code is “feeds_data”`, not “feeds”. Anyway, I ran your code with both keys and got no errors.

Note that there are a few undefined things in your code, the issue may lie in the missing bits.

Apparently there is no solution, many people are having this problem for months and nobody took care of solving it.

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