Python grpc protobuf存根生成问题:--grpc_out:protoc-gen-grpc:插件失败,状态码为1 [英] Python grpc protobuf stubs generation issue: --grpc_out: protoc-gen-grpc: Plugin failed with status code 1
问题描述
正如问题所述,我从源代码编译了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存根.由于which grpc_python_plugin
不返回任何内容,因此出现以下错误:
As the question says, I compiled grpc from source and also did sudo pip install grpcio
, however, the which grpc_python_plugin
doesn't return anything. This is a problem because the grpc python example for route_guide requires me to run protoc -I . --python_out=. --grpc_out=. --plugin=protoc-gen-grpc='which grpc_python_plugin' ./route_guide.proto
in order to generate the python stubs. Since, which grpc_python_plugin
doesn't return anything, I get the following error:
: 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,则必须使用这些方法.任何帮助将不胜感激.
If I shorten the command I'm trying to run to:protoc -I . --python_out=. ./route_guide.proto
, it generates the route_guide_pb2.py file but without the Servicer and Stub classes, and server and stub methods. Ofc, these methods are necessary if one wants to use grpc for any purpose. Any help would be appreciated.
推荐答案
听起来您PATH
中没有/usr/local/bin
; make install
默认情况下使用/usr/local
前缀.或者,编译后grpc_python_plugin
应该在bins/opt/
中.
It sounds like you don't have /usr/local/bin
in your PATH
; make install
uses a prefix of /usr/local
by default. Alternatively, after compilation grpc_python_plugin
should be in bins/opt/
.
这篇关于Python grpc protobuf存根生成问题:--grpc_out:protoc-gen-grpc:插件失败,状态码为1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!