【问题标题】:KeyError: 'selector' while deploying streamlit python app on HerokuKeyError:在 Heroku 上部署 streamlit python 应用程序时出现“选择器”
【发布时间】: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


    【解决方案1】:

    DataFrame 样式现在有点小问题,因为 Streamlit 依赖于 pandas 1.1 中更改的私有 pandas 方法:

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

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

    【讨论】:

      【解决方案2】:

      这也是在本地运行streamlit的问题。我降级了熊猫,但这导致了其他问题。有什么建议?我可能选择了错误的日子来尝试学习流式...

      【讨论】:

        猜你喜欢
        • 2020-11-08
        • 2021-06-29
        • 2021-03-25
        • 1970-01-01
        • 2020-11-10
        • 2013-09-30
        • 2011-05-15
        • 2018-05-30
        • 1970-01-01
        相关资源
        最近更新 更多