Bad 'setIn' index 13 (should be between [0, 2])

Hi,

I am using the st.empty() to reserve some space where to print elements after. I am getting an error message everytime I use the app because of this:

This is my code:

import streamlit as st
from ast import literal_eval
import plotly.express as px

box1 = st.empty()
box2 = st.empty()
box3 = st.empty()
box4 = st.empty()
box5 = st.empty()
box6 = st.empty()

def charge_dict(name):

try:

    f = open(name, "r")
    input = f.read()

# If file does not exist, create a new one with the blank values array, close it and read the content again
except FileNotFoundError:

    st.write("Error: no file found")

# Once the content is saved in input string, close the file
finally:

    f.close()

# Read the input string and generate a dictionary out of it
results = literal_eval(input)

return results

def results_menu():

results = charge_dict("results.txt")
information = charge_dict("output.txt")

questions = []

for i in range(0, information["Number of questions"]):

    questions.append(information["Questions"][i])

box1.selectbox(label="Select a question to see the results", options=questions, index=0)

How can I fix this? I think it might be a bug

I am using…

  • Streamlit version: 0.82.0
  • Python version: Python 3.9.2
  • Using virtualenv
  • OS version: Windows 10
  • Browser version: Chrome 90.0.4430.93

Hey, is someone there?

@bocanegra Not sure if you already found a solution, but I was experiencing the same issue trying to build what is essentially the animate elements from the official documentation The only major difference is that I am running the chart.add_rows in a separate thread. The solution for me was to call thread.join() after creating my thread and adding the report context. Credits for the solution go to tim.

thread = threading.Thread(target=my_func, args=my_args)
thread = add_report_ctx(thread)
thread.start()
thread.join()