使用tensorbaoardx报错——Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.

 

 

运行代码报错:

from tensorboardX import SummaryWriter

 

 

 

 

报错内容:

 

 

 

发生异常: TypeError
Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
 

 

 

 

 

 

=================================================

 

 

 

 

根据报错信息提供的链接:

https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

 

 

根据官方给出的资料,可以知道Google的序列化协议protobuf已经由版本3.20.1升级到4.21.6,一些需要调用旧版本protobuf的python库将出错,这种情况需要通过设置环境变量或者安装旧版本的protobuf来解决。

 

 

查看一下本地的protobuf版本:

pip list

 

显示:

 

 

大概率确定是安装的protobuf版本高了的问题,更新低版本的protobuf,具体操作:

pip install --upgrade protobuf==3.20.1

 

 

------------------------------------------------------

 

 

 

再次运行,不报错,成功解决。

 

posted on   Angry_Panda  阅读(2054)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 手把手教你更优雅的享受 DeepSeek
· AI工具推荐:领先的开源 AI 代码助手——Continue
· 探秘Transformer系列之(2)---总体架构
· V-Control:一个基于 .NET MAUI 的开箱即用的UI组件库
· 乌龟冬眠箱湿度监控系统和AI辅助建议功能的实现

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

统计

点击右上角即可分享
微信分享提示