正如问题所说,我从源代码处编译了grpc,并且也执行了sudo pip install grpcio
,但是which grpc_python_plugin
没有返回任何内容。这是一个问题,因为grpc python的route_指南示例要求我运行protoc -I . --python_out=. --grpc_out=. --plugin=protoc-gen-grpc='which grpc_python_plugin' ./route_guide.proto
以便生成python存根。由于,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类以及server和Stub方法。Ofc,这些方法是必要的,如果一个人想使用grpc的任何目的。任何帮助都将不胜感激。
编辑:
显然,gRPC github网站上有关于这个问题的公开问题。
Protoc
似乎与grpc_python_plugin
存在兼容性问题?我通过安装grpc_tools
解决了这个问题,然后使用grpc_tools.protoc
而不是protoc
。有用的python教程:https://grpc.io/docs/tutorials/basic/python.html
见协议问题[791和4961]:
听起来你的
PATH
中没有/usr/local/bin
;make install
默认使用前缀/usr/local
。或者,编译后grpc_python_plugin
应该在bins/opt/
中。若要解决此错误,请确保系统上已安装
grpc_python_plugin
。 在python平台上pip install grpcio
不安装特定于平台的插件,因此必须通过以下步骤分别安装它们cd grpc
(grpc存储库)git submodule update --init
make grpc_python_plugin
这将为您构建
grpc
python插件。现在,找出系统上grpc_python_plugin
的位置,让我们称之为binary_path
如果二进制路径在
$PATH
环境变量(echo $PATH
)下,则可以继续。但是,如果不在$PATH变量下,则有两个选项将
run_codegen.sh
更新为--plugin=protoc-gen-grpc=binary_path
或者,将二进制文件复制到$PATH
环境变量跟踪的某个位置相关问题 更多 >
编程相关推荐