Compiling gRPC protobuf - "program not found or is not executable"

1.4k views Asked by At

I am struggling to compile my .proto files to generate the gRPC stubs in Python.

My current working directory is ./predictor. I have a simulator.proto file in the ./proto folder.

The readme for the project I am working on says I should run

protoc -I ../proto/ --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` ../proto/simulator.proto

This fails and gives me

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

I try it with python -m grpc_tools.protoc ... and it still doesn't work. I have double checked that I have grpc installed, I have reinstalled it with pip, and also git clone'd the grpc folder and built from the source. I am not sure what else to do. Does anyone have an idea?

1

There are 1 answers

3
DazWilkin On BEST ANSWER

You can't (easily!?) use protoc for Python and are best placed using the module as you describe.

The command should be similar to:

python \
-m grpc_tools.protoc \
--proto_path=../proto \
--python_out=. \
--grpc_python_out=. \
../proto/*.proto

Assuming that you have a parent directory called proto containing at least one .proto file and you run this command from python:

.
├── protos
│   └── x.proto
└── python
    ├── x_pb2_grpc.py
    └── x_pb2.py

What errors do you get when using the module?