在TensorBoard使用结束,想要继续进行模型的训练、评估时,出现上面的问题。
【报错原因】
问题源自所用的google.protobuf版本过低。在更新的版本里,builder模块已经被迁移到了google.protobuf包内,不再位于google.protobuf.internal路径下。
【解决方案】
提升protobuf库的版本:
pip install --upgrade protobuf
【相关问题】TypeError: Descriptors cannot be created directly.
TypeError: Descriptors cannot 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).
类型错误:描述符不能直接创建。 如果这个调用来自_pb2.py文件,你的生成代码已经过时,必须使用protoc >= 3.19.0重新生成。 如果你不能立即重新生成你的原型,其他可能的解决方法包括:
- 将protobuf包降级到3.20.x或更低版本。
- 设置环境变量PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python(但这将使用纯Python解析,速度会慢得多)。
【错误原因】
问题是由于使用了过高版本的protobuf库所导致的。在protobuf的更新版本中,为了提升性能,对Descriptor对象的生成机制进行了调整。
【解决方案】
pip uninstall protobuf # 卸载原有protobuf库,[Y/n]时输入Y
pip install protobuf==3.20.0
【注】这两个问题相互影响,经常一起出现