- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
如问题所述,我从源代码编译了 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/
这个问题在这里已经有了答案: protoc-gen-go-grpc: program not found or is not executable (11 个回答) 11 个月前关闭。 我正在尝试设置
我正在关注有关使用 grpc 的教程,我应该使用插件来生成源代码,但我被困在如何使用 --grpc_out 和 --plugin 标志上。 以下是当前的挑战。 从https://search.mave
如问题所述,我从源代码编译了 grpc 并执行了 sudo pip install grpcio,但是,which grpc_python_plugin 没有返回任何内容。这是一个问题,因为 rout
我是一名优秀的程序员,十分优秀!