gpt4 book ai didi

Python grpc protobuf stub 生成问题 : --grpc_out: protoc-gen-grpc: Plugin failed with status code 1

转载 作者:太空狗 更新时间:2023-10-30 02:43:03 42 4
gpt4 key购买 nike

如问题所述,我从源代码编译了 grpc 并执行了 sudo pip install grpcio,但是,which grpc_python_plugin 没有返回任何内容。这是一个问题,因为 route_guide 的 grpc python 示例要求我运行 protoc -I 。 --python_out=。 --grpc_out=。 --plugin=protoc-gen-grpc='which grpc_python_plugin' ./route_guide.proto 为了生成 python stub 。因为 which grpc_python_plugin 没有返回任何东西,所以我得到以下错误:

: program not found or is not executable
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1.

如果我将要运行的命令缩短为:protoc -I 。 --python_out=。 ./route_guide.proto,它生成 route_guide_pb2.py 文件,但没有 Servicer 和 Stub 类,以及服务器和 stub 方法。当然,如果出于任何目的想要使用 grpc,这些方法都是必需的。任何帮助将不胜感激。

最佳答案

python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. my_proto.proto

编辑:

显然,gRPC github 站点上有关于此问题的未解决问题。 Protoc 似乎与 grpc_python_plugin 有兼容性问题?我通过安装 grpc_tools 解决了这个问题,然后使用 grpc_tools.protoc 而不是 protoc

$ pip install grpcio-tools
$ pip install googleapis-common-protos

有用的 Python 教程:https://grpc.io/docs/tutorials/basic/python.html

参见协议(protocol)问题 [791 和 4961]:

关于Python grpc protobuf stub 生成问题 : --grpc_out: protoc-gen-grpc: Plugin failed with status code 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34713861/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com