Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Viewing all articles
Browse latest Browse all 9596

Generating grpc stubs for Python from the command line

$
0
0

The GRPC quickstart guide refers to generating GRPC stubs using python code similar to run_codegen.py

When you look in this file, you see what appears to be a command line like: protoc --python_out=. --grpc_python_out=. myfile.proto

However, if you actually try to execude that command line with either protoc 2.6.1 or 3.0.0, you get this error:

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

The solution is to make sure that the grpcio-tools python package is installed and use the command line in the tutorial instead: python -m grpc.tools.protoc --proto_path=. --python_out=. --grpc_python_out=. proto2.proto

As far as I am able to tell from the output, python -m grpc.tools.protoc is equivalent to protoc 3.0.0 in which case, if you want to use GRPC and python, you don't even need to have the protoc binary installed anywhere else anymore and just rely on the dynamic library version in grpcio-tools .


Viewing all articles
Browse latest Browse all 9596

Trending Articles