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

Colab中通过LocalTunnel运行Streamlit失效问题求助

问题原因与解决方法

问题原因

报错AttributeError: Enum LabelVisibilityOptions has no value defined for name 'ValueType'是Streamlit与Colab预装的protobuf版本不兼容导致的:

  • 新版protobuf(3.21及以上)移除了枚举类型的ValueType属性
  • 旧版Streamlit代码中仍依赖该属性,启动时触发错误
  • 后续的504网关超时是因为Streamlit服务未成功启动,LocalTunnel无法连接到有效服务

解决步骤

  1. 卸载冲突的protobuf版本,安装兼容的旧版本
    !pip uninstall protobuf -y
    !pip install protobuf==3.20.3 streamlit -q
    
  2. 保留原有的app.py代码不变:
    %%writefile app.py
    import streamlit as st
    st.write('# test')
    
  3. 重新启动Streamlit与LocalTunnel服务:
    !streamlit run /content/app.py & npx localtunnel --port 8501
    

补充说明

  • 如果仍有问题,可以尝试指定明确的Streamlit兼容版本,比如streamlit==1.19.0,确保和protobuf 3.20.3完全匹配
  • 操作完成后,点击LocalTunnel生成的链接,即可正常访问Streamlit应用

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 05:25:13