【发布时间】:2020-11-21 16:37:36
【问题描述】:
我已经通过 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 上部署时仍然出现错误。我能做些什么来纠正这个问题?非常感谢任何帮助。
【问题讨论】:
标签: python python-3.x pandas heroku streamlit