Deployed streamlit app suddenly stop working but still working when launch locally

Hi all, require some help in helping me to debug this. My deployed streamlit app suddenly stopped working, however it still works fine when launched locally. Appreciate if anyone could help me on this.

These are my files in Github: GitHub - jethrowong1803/streamlit-W.W.M.J

Below is the error:

KeyError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/”, line 535, in _run_script
exec(code, module.dict)
File “/mount/src/streamlit-w.w.m.j/”, line 219, in
cluster0_symbol, cluster1_symbol, cluster2_symbol, cluster0, cluster1, cluster2, sp500_cumm = load_data()
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/”, line 212, in wrapper
return cached_func(*args, **kwargs)
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/”, line 241, in call
return self._get_or_create_cached_value(args, kwargs)
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/”, line 268, in _get_or_create_cached_value
return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/caching/”, line 324, in _handle_cache_miss
computed_value = self._info.func(*func_args, **func_kwargs)
File “/mount/src/streamlit-w.w.m.j/”, line 63, in load_data
stockdata = stockdata.stack().reset_index().rename(index=str, columns={“level_1”: “Symbol”}).sort_values([‘Symbol’,‘Date’])
File “/home/adminuser/venv/lib/python3.9/site-packages/pandas/core/”, line 7159, in sort_values
keys = [self._get_label_or_level_values(x, axis=axis) for x in by]
File “/home/adminuser/venv/lib/python3.9/site-packages/pandas/core/”, line 7159, in
keys = [self._get_label_or_level_values(x, axis=axis) for x in by]
File “/home/adminuser/venv/lib/python3.9/site-packages/pandas/core/”, line 1910, in _get_label_or_level_values
raise KeyError(key)

  • as the lib versions are not pinned, there may have been changes to a library
  • yfinance is known to break regularly because the interface is constantly changing
  • there is no error/exception handling for stockdata if yfinance does not deliver the expected result
  • I would take a very close look at the stockdata dataframe
  • while debugging i would remove the cache decorators temporarily

Hi thanks alot for the quick reply. Apparently there’s some changes to how the stockdata is loaded into the pandas dataframe. Have done the changes and is working fine now. Thanks!

Feel free to check my app out

1 Like

hi @jethrowong1803
looks good

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