• 使用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

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

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

  • 相关阅读:
    Java实战项目收集
    Drebin数据集
    网络“法官”
    沉醉
    孔方兄
    《Qt 5.9 C++开发指南》例程源码
    《论语》中那些耳熟能详的词汇
    破祟
    Qt使用UI编辑器添加的控件Icon运行时不显示
    Ubuntu格式化SD卡
  • 原文地址:https://www.cnblogs.com/devilmaycry812839668/p/16717855.html
Copyright © 2020-2023  润新知