Streamlit报错“Descriptors cannot be created directly”问题求助
解决Streamlit运行时“Descriptors cannot be created directly”错误
错误原因
这个错误核心原因是protobuf版本不兼容。Streamlit依赖特定版本的protobuf库,当环境中安装的protobuf版本过高(如≥4.21.0),就会触发描述符无法直接创建的问题。
修复步骤
- 卸载当前环境中的protobuf:
pip uninstall protobuf -y - 安装Streamlit兼容的指定版本protobuf(推荐3.20.x系列,示例用3.20.3):
pip install protobuf==3.20.3 - 用正确方式启动Streamlit脚本(不要直接用Sublime的运行按钮):
streamlit run 你的脚本文件名.py
验证修复
执行以下命令确认protobuf版本:
pip show protobuf
输出中版本号显示为3.20.x即说明安装正确。
内容的提问来源于stack exchange,提问作者Sukirti Mishra
相关产品推荐
相关产品推荐

