如何使用 proto3 在 Python 中创建 gRPC 服务器?

How to create a gRPC server in Python using proto3?

根据这个 http://www.grpc.io/docs/tutorials/basic/python.html#creating-the-server and the examples here https://github.com/grpc/grpc/tree/v1.0.0/examples/python/route_guide,当我生成我的 _pb2.py 文件时,应该创建几个名为 *Stub*Servicer 的 类。但是,我生成的 _pb2.py 文件不包含这样的内容。

这就是我生成 _pb2.py 文件的方式:

protoc --proto_path=.venv/lib/python3.5/site-packages/grpc/tools/_proto/ --proto_path=.  --python_out=voyager/ voyager.proto

proto3 是否有什么特殊之处意味着这些 类 不会生成?或者我丢失的 protoc 标志?我似乎不知道如何创建 gRPC 服务器。

您好像不见了--grpc_python_out=voyager/。涉及到两个插件:Protobuf Python 和 gRPC Python。你只是 运行 Protobuf 中的一个。