Deployment doesn't work on streamlit cloud, but works in local

Streamlit dashboard works locally but not on cloud.

Here’s my app:

I can’t figure out why. Please help!

Hi @tai_L,

Thanks for sharing your question with the community! Check out our guidelines on how to post an effective question here and pleased edit your question to include a code snippet + link to your app’s GitHub repo

@tai_L there is an issue with your code (line 160) in your file
br2_rent = df_rent_chart['2 bedroom'].iloc[0]

Please debug this yourself by running above that line:
st.write(df_rent_chart['2 bedroom'])

Possible issues:

  1. The .iloc[0] indexing is used to access the first row of the column but the Pandas Series are empty
  2. check the datatype of the Pandas Series is correct
  3. check for spelling mistakes e.g. you ment ‘2_bedroom’ → also preferably do not use spaces in naming conventions of columns.

Please note if you are trying to access the 1st row of your Pandas Series ‘2 bedroom’ or what your goal is and provide your code or sample please if after debugging it you cannot figure it out. If you found the solution let me know!

Verify the issue is not cookies by using a “private” browsing window.

Hi, I added that line and it looks like the df is coming in empty. It is suppose to read a csv file on a public folder in Github ( The same script that works on my local drive also pulls in the same csv file from Github. Not sure why it is not reading it after I put it on Github/Streamlit cloud?

@tai_L without seeing your code on e.g. github to debug harder to provide a suggestion.

Locally I have no issues pulling up the dataframe with:

# URL of the CSV file
url = ''

# Read the CSV file from the URL
df_rent = pd.read_csv(url)
# Display the DataFrame
# display the value of last row of column **fmr_2br** in Streamlit

Currently you have a different error with code in line 168 in file

File "/app/re_dashboard/", line 168, in <module>
    br2_rent = df_rent_chart['2 bedroom'].iloc[-1]

I think you should start debugging if you have the column ‘2 bedroom’ inside your dataframe called df_rent_chart and check for typos.

Please provide a link to your code in github so I can debug it or debug it yourself by printing or st.write() in streamlit the dataframe ‘df_rent_chart’ e.g. st.write(df_rent_chart)

omg I finally figured it out. I was looking for a string variable but the df column is an integer. I was using an ‘isin’ function. Strange thing was, it works fine on my desktop but doesn’t work once I upload into Streamlit cloud. And it was working fine on the Streamlit cloud two weeks ago. I think it is because Streamlit is using Python 3.9 and I have Python 3.8 on my desktop. Tks for all the help!

1 Like

I had similar issue in the last days, in a line related to the Pandas usage.

Then, I realized in local environment Pandas 1.5.3 was used. But in Streamlit Cloud Pandas 2.0.1 was being installed, even requirements.txt requesting Pandas 1.5.3.

Then I adjusted my code to be compatible with Pandas 2.0.1 and the issue was solved.

The strangest thing for me is the app was running fine for 3 months in the Cloud, then it stopped working suddenly after waking up. In the last weeks, I had 2 similar events (with Altair and Pandas). I am using Streamlit 1.18.1 but it seems changes in other Streamlit builds (1.19, 1.20, etc) crashed my app.

I suggest you to take a look in the logs from Streamlit Cloud and compare them with the module versions installed in your machine. Maybe you need some adjustments.

That was exactly it! I updated my code to be compatible with pandas 2.0.1 and it works fine now!

Samething happened to me – the app was running for months and then it just stopped working!