python 远程调试grpc报错版本问题

176 阅读1分钟

报错信息

TypeError: Descriptors cannot not be created directly.

image.png

解决办法

尝试把远程的protobuf版本降级到3.19.0,

  1. 使用命令 pip show protobuf 发现版本是4.21.6
  2. 卸载高版本的protobuf pip uninstal protobuf
  3. 安装新版本的protobuf pip install protobuf==3.19.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

安装时发现报错,但是不影响正常使用,报错大致是因为 grpcio-tools 需要较高版本的protobuf