【问题标题】:AttributeError: module 'streamlit' has no attribute '_is_running_with_streamlit'. This attribute used to work properly but now it doesn't work anymoreAttributeError: 模块 \'streamlit\' 没有属性 \'_is_running_with_streamlit\'。该属性以前可以正常工作,但现在不能正常工作了
【发布时间】:2022-11-06 19:23:19
【问题描述】:
from streamlit.web import cli as stcli
import sys

if __name__ == '__main__':
    if st._is_running_with_streamlit:
        main()
    else:
        sys.argv = ["streamlit", "run", sys.argv[0]]
        sys.exit(stcli.main())

上面的代码过去可以正常工作,但现在当我不再工作时升级我的流线型版本 1.14.0.

当我尝试在 PyCharm IDE 中运行我的程序时,它将显示以下问题!

Traceback (most recent call last):
  File "C:\Users\juroy\PycharmProjects\TikTokAnalytics\app.py", line 66, in <module>
    if st._is_running_with_streamlit:
AttributeError: module 'streamlit' has no attribute '_is_running_with_streamlit'

最新的更新是什么?

【问题讨论】:

    标签: python streamlit


    【解决方案1】:

    我从 Streamlit 社区获得了解决方案,我实际上使用的是 Streamlit 不一定支持的内部 API。他们不建议使用这个。

    要替换该代码以使其正常工作,Streamlit 建议我可以使用它:

    from streamlit import runtime
    runtime.exists()
    

    所以我上面的代码 sn-p 需要修改为:

    from streamlit.web import cli as stcli
    from streamlit import runtime
    import sys
    
    if __name__ == '__main__':
        if runtime.exists():
            main()
        else:
            sys.argv = ["streamlit", "run", sys.argv[0]]
            sys.exit(stcli.main())
    

    【讨论】:

      猜你喜欢
      • 2018-09-27
      • 2013-05-24
      • 2021-11-11
      • 1970-01-01
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      • 2017-02-06
      • 1970-01-01
      相关资源
      最近更新 更多