Python gprc AttributeError:“NoneType”对象没有属性“message_types_by_name”

gua*_*lan 6 grpc-python

我只想完成一个简单的演示,但收到此错误消息。

Traceback (most recent call last):
  File "E:/grpc/biliService.py", line 10, in <module>
    import hello_bilibili_pb2 as pb2
  File "E:\grpc\hello_bilibili_pb2.py", line 21, in <module>
    _HELLODEWEIREQ = DESCRIPTOR.message_types_by_name['HelloDeweiReq']
AttributeError: 'NoneType' object has no attribute 'message_types_by_name'
Run Code Online (Sandbox Code Playgroud)

小智 1

grpcio==1.30.0\ngrpcio-tools==1.30.0\n
Run Code Online (Sandbox Code Playgroud)\n

最新grpcio版本1.44.0生成不兼容的pb2文件,所以我看到了同样的问题,我降级grpcio 1.30.0\xef\xbc\x8c 并且它有效。

\n