You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Streamlit调试报错:Bad message format及SessionInfo未初始化

在PyCharm中调试Streamlit应用遇到的问题

背景

使用PyCharm作为IDE,调试基于Python 3.11和Streamlit 1.32.0的应用代码。

当前尝试方案

参考相关方案,通过导入streamlit.web.bootstrap的方式启动应用。

示例代码

starter.py 文件内容

try:
    # for streamlit >= 1.12.1
    from streamlit.web import bootstrap
except ImportError:
    from streamlit import bootstrap

real_script = 'main.py'
bootstrap.run(real_script, f'run.py {real_script}', [], {})

main.py 文件内容

import streamlit as st

st.text('hello world')

浏览器(Firefox)报错信息

Bad message format
Tried to use SessionInfo before it was initialized

补充信息

使用命令streamlit run main.py可以正常启动应用,问题疑似与streamlit.web.bootstrap的调用方式相关。


内容的提问来源于stack exchange,提问作者CFF

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 22:05:55