KeyError: 'selector' while deploying streamlit python app on Heroku

KeyError: 'selector' while deploying streamlit python app on Heroku

我已经通过 heroku 上的 streamlit 部署了我的 python 应用程序。我面临的唯一问题是,当我尝试在 heroku 上显示带有背景渐变的样式数据框时,它会抛出以下错误:

KeyError: ‘selector’
Traceback:
File “/app/.heroku/python/lib/python3.6/site-packages/streamlit/ScriptRunner.py”, line 319, in _run_script
exec(code, module.dict)
File “/app/test.py”, line 243, in
print(st.dataframe(etf.format_world_data(world_indices(), usd=usd)[1]))
File “/app/.heroku/python/lib/python3.6/site-packages/streamlit/DeltaGenerator.py”, line 921, in dataframe
set_data_frame, “dataframe”, element_width=width, element_height=height
File “/app/.heroku/python/lib/python3.6/site-packages/streamlit/DeltaGenerator.py”, line 426, in _enqueue_new_element_delta
rv = marshall_element(msg.delta.new_element)
File “/app/.heroku/python/lib/python3.6/site-packages/streamlit/DeltaGenerator.py”, line 918, in set_data_frame
data_frame_proto.marshall_data_frame(data, delta.data_frame)
File “/app/.heroku/python/lib/python3.6/site-packages/streamlit/elements/data_frame_proto.py”, line 54, in marshall_data_frame
_marshall_styles(proto_df.style, df, styler)
File “/app/.heroku/python/lib/python3.6/site-packages/streamlit/elements/data_frame_proto.py”, line 74, in _marshall_styles
css_styles = _get_css_styles(translated_style)
File “/app/.heroku/python/lib/python3.6/site-packages/streamlit/elements/data_frame_proto.py”, line 116, in _get_css_styles
cell_selector = cell_style[“selector”] # a string of the form ‘row0_col0’

该代码在我的本地机器上运行良好,并且完美地显示了样式化的数据框。我也试过使用st.write、st.dataframe和st.table,但是部署到heroku上还是报错。我该怎么做才能纠正这个问题?非常感谢任何帮助。

DataFrame 样式现在有点问题,因为 Streamlit 依赖于私有 pandas 方法,该方法在 pandas 1.1:

中发生了变化

https://github.com/streamlit/streamlit/issues/1777

尝试在 requirements.txt 文件中为 pandas <1.1 设置硬限制,然后使用 Heroku 重试。

这也是一个问题 运行 本地流化。我降级了 pandas,但这导致了其他问题。有什么建议么?我可能选错了学习 streamlit 的日子...