TypeError: Descriptors cannot not be created directly.

1. 报错信息

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.

 

 2. 解决方案

  点击ternimal输入pip uninstall protobuf将现有版本的卸载,然后输入pip install protobuf 3.19.0即可。由于网速会影响成功率,我运行了两次才装成功的。

 

 3. 原因解析

  

TypeError:不能直接创建描述符。
如果此调用来自 _pb2.py 文件,则您生成的代码已过期,必须使用 protoc >= 3.19.0 重新生成。
如果您不能立即重新生成原型,其他一些可能的解决方法是:
1. 将 protobuf 包降级到 3.20.x 或更低版本。
2. 设置 PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (但这将使用纯 Python 解析并且会慢得多)。

 

 

posted @   JRS077  阅读(14324)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示