Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc_python_plugin not installed with pip install grpcio-tools? #15675

Closed
gyang274 opened this issue Jun 7, 2018 · 2 comments
Closed

grpc_python_plugin not installed with pip install grpcio-tools? #15675

gyang274 opened this issue Jun 7, 2018 · 2 comments

Comments

@gyang274
Copy link

gyang274 commented Jun 7, 2018

I am experimenting the python grpc hello world example.

gPRC tools is installed with python3.6 pip.

$ python -m pip install grpcio
$ python -m pip install grpcio-tools

$ python -m grpc_tools.protoc --version
libprotoc 3.5.1

And compile using grpc tools as a python module works fine.

$ python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. helloworld.proto

I would like to also try to using the system protoc to compile, however, this fails due to grpc_python_plugin is not found.

$ protoc --version
libprotoc 3.5.1

$ protoc -I. --python_out=. --grpc_python_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` helloworld.proto

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

I then built grpc_python_plugin from gits, and it works fine.

$ git clone https://github.com/grpc/grpc.git
$ git submodule update --init
$ make grpc_python_plugin

$ ls ~/gits/grpc/bins/opt/
grpc_python_plugin  protobuf

$ protoc -I. \
    --python_out=. \
    --grpc_python_out=. \
    --plugin=protoc-gen-grpc_python=~/gits/grpc/bins/opt/grpc_python_plugin \
    helloworld.proto

In summary, my questions:

  1. From my understanding, the first approach, e.g., using python module is preferred, right?
  2. What is the difference between the two approaches, python module grpc_tools, and protoc with grpc plugin?
  3. Is it possible to get the grpc_python_plugin via pip install, or similar way?

PS:

I explored protoc with grpc plugins to compile python and javascript out together, which works fine.

protoc -I. \
    --python_out=. \
    --grpc_python_out=. \
    --plugin=protoc-gen-grpc_python=`which grpc_python_plugin` \
    --js_out=import_style=commonjs,binary:. \
    --grpc_out=. \
    --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` \
    helloworld.proto

Thank you very much!

@mehrdada
Copy link
Member

gRPC Python's grpcio-tools package, unlike the other languages, does not ship protoc and grpc_python_plugin as separate binaries. They are combined together into a single Python extension module and accessible as documented and as you noted in your question. The main advantage of the way gRPC Python does things is that you can simply pip install it and fallback on building from source even if a prebuilt binary for your architecture is not available.

We do not distribute pre-built binaries for grpc_python_plugin, but you should be able to build it by taking the gRPC git source tree and building it:

$ git clone --recursive https://github.com/grpc/grpc
$ cd grpc && make plugins -j 12
$ ls bins/opt/grpc_python_plugin

@lock lock bot locked as resolved and limited conversation to collaborators Sep 28, 2018
@yashykt
Copy link
Member

yashykt commented Jun 24, 2021

From @iamnoah #26210 -
I would just comment on #15675 if it were not locked, but just wanted to point out there is an easy solution for those looking for a binary for the python gRPC plugin:

pip install grpclib protobuf
The plugin binary is then available as protoc-gen-grpclib_python or protoc-gen-python_grpc in the bin/ directory for your python env. (If you are using buf, it can be used as name: python_grpc or name: grpclib_python.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants