Error while running Plotting Demo

Hello,

I encounter this error while running the Plotting Demo.

It gives the following, in case you cannot see the screenshot: StreamlitAPIException : ‘RangeIndex’ object has no attribute ‘step’

Hi @tabsa, thanks for joining the community!

What version of Streamlit are you using, and what operating system?

Hi @randyzwitch, thanks for the reply. I’m using the following:

  • strealit version 0.58.0

  • Windows 10

I installed Streamlit 0.58 in a fresh Conda environment on Windows 10 and the plotting demo (and all the rest) worked with Microsoft Edge.

Did you install Streamlit in a fresh Python environment or globally? Also, which browser are you using?

I use google chrome and test in microsoft edge that gives another error.

I installed in a global Python environment that I normally use, didn’t create a fresh one just for streamlit.

Unfortunately, I think the global environment might be your answer then. The pip installer is pretty notorious for not solving environments correctly, so it could the case that one of your global packages is on a version of a dependency we don’t support.

Do you have a suppport gui about pip install in a virtual environment? Or maybe another way would be to update to the version required by streamlit the packages used in this demo. Unfortunately, I don’t know all the packages (and respectives version) used here, would be OK to provide this info?

I would definitely recommend getting used to using environments over trying to make your global environment conform by checking individual package versions. You could start here:

https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv

Thanks for the recommendation. I didn’t try yet the virtual environments to avoid the problems with the pip installer, but I realize one thing while I run the Plotting Demo in my OS.

import time
import numpy as np

progress_bar = st.sidebar.progress(0)
status_text = st.sidebar.empty()
last_rows = np.random.randn(1, 1)
chart = st.line_chart(last_rows)

for i in range(1, 101):
new_rows = last_rows[-1, :] + np.random.randn(5, 1).cumsum(axis=0)
status_text.text("%i%% Complete" % i)
chart.add_rows(new_rows)
progress_bar.progress(i)
last_rows = new_rows
time.sleep(0.05)

progress_bar.empty()

From the code of the plotting demo, the command chart.addrows(newrows) is the troublemaker. When I replace it for chart.line_chart(newrows), the demo runs but without stacking the newrows in the same line_chart. Is there any explanation for this?

Given that it runs in a clean environment for me on Windows, I really think you need to try the virtual environment. It’s hard to point at that line of code as the error when we can’t reproduce the issue.

1 Like

Just to let know, I was able to run the Plotting Demo using the virtual environment as suggested. Thanks a lot for the support!

1 Like