快速开始

https://grpc.io/docs/quickstart/python.html

开始之前

确保 pip 版本 8 或更高:

python -m pip install --upgrade pip

如果在虚拟环境中, 就先切换到虚拟环境, 然后再升级

安装gRPC

gRPC

python -m pip install grpcio

在 El Capitan OSX, 可能会报如下错误:

OSError: [Errno 1] Operation not permitted: '/tmp/pip-qwTLbI-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

此时使用如下命令

python -m pip install grpcio --ignore-installed

安装gRPC工具

Python gRPC tools 包括 protocol buffer 编译器 protoc 和用于生成服务器和客户端代码的插件, generating server and client code from .proto service definitions. For the first part of our quickstart example, we’ve already generated the server and client stubs from helloworld.proto, but you’ll need the tools for the rest of our quickstart, as well as later tutorials and your own projects.

安装 gRPC tools:

python -m pip install grpcio-tools