David - Musings of an SRE

Installing GRPC, Protobuf and its dependencies for Python Development

Been having some trouble getting my local machine setup for GRPC development lately.

Hopefully this quick walkthrough will help someone out.

Prerequisites

  • You’re on the Python 2.X branch. Python 3.X is currently not supported for the official grpc library

Setup

  1. Install Protobuf
$ pip install "protobuf>=3.0.0a2"

Note: In order to support protobuf syntax 3, you’ll need to ensure your version of protobuf is at least 3.0.0a2.

  1. Install grpcio
$ pip install grpcio
  1. Make the plugin:
$ git clone https://github.com/grpc/grpc.git
$ cd grpc
$ sudo make grpc_python_plugin
davidc@grimlock-home ~/codebase/python/grpc (master) $ sudo make grpc_python_plugin
[HOSTLD]  Linking /home/davidc/codebase/python/grpc/bins/opt/grpc_python_plugin
/usr/bin/ld: warning: libprotobuf.so.10, needed by //usr/local/lib/libprotoc.so, may conflict with libprotobuf.so.8
/usr/bin/ld: /home/davidc/codebase/python/grpc/libs/opt/libgrpc_plugin_support.a(python_generator.o): undefined reference to symbol '_ZN6google8protobuf2io7Printer5PrintEPKcS4_RKSsS4_S6_S4_S6_S4_S6_'
//usr/local/lib/libprotobuf.so.10: error adding symbols: DSO missing from command line

If you are getting an error similar to this while doing your python_plugin making, you might want to:

$ sudo find /usr/lib -name "*protobuf*" -delete
$ sudo ldconfig
$ sudo make grpc_python_plugin
$ cd /usr/local/bin && ln -s /path/to/grpc/bins/opt/grpc_python_plugin

Note: This will remove all your older versions of protobuf in your shared libraries. Do this only if you know what you’re doing.


Once all of these is completed, check out the rest of the tutorial and get your grpc on!

References: