基于http/2的rpc框架
grpcio的Python项目详细描述
grpc python的包。
支持的Python版本
python=3.5
不推荐的python版本
python==2.7。Python2.7支持将于2020年1月1日取消。
安装
grpc python可用于linux、macos和windows。
从pypi安装
如果在本地安装…
$ pip install grpcio
其他系统范围(在ubuntu上)…..
$ sudo pip install grpcio
如果您在Windows上,请确保安装了pip.exe
组件
安装python时(如果不回去安装!)然后调用:
$ pip.exe install grpcio
Windows用户可能需要从运行为的命令行调用pip.exe
管理员。
N.B.在Windows和Mac OS X上,必须有一个最新版本的pip
从pypi中检索正确的轮子。一定要升级到最新版本
版本!
从源安装
从源代码构建需要有python头(通常是
名为python-dev
)的包。
$ export REPO_ROOT=grpc # REPO_ROOT can be any directory of your choice $ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc $REPO_ROOT $ cd $REPO_ROOT $ git submodule update --init # For the next two commands do `sudo pip install` if you get permission-denied errors $ pip install -rrequirements.txt $ GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .
当前无法在Windows上从源代码安装Python。事情可能会成功 在msys2中为您提供(遵循linux的说明),但它并不是正式的 目前支持。
故障排除
帮助,我…
…尝试安装时请参见a
pkg_resources.VersionConflict
。 GRPC这可能是因为
pip
不拥有有问题的依赖项, 这可能是因为您的操作系统的包管理器拥有 它。您需要强制安装依赖项:pip install --ignore-installed $OFFENDING_DEPENDENCY
例如,如果出现如下错误:
Traceback (most recent call last): File "<string>", line 17, in <module> ... File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 509, in find raise VersionConflict(dist, req) pkg_resources.VersionConflict: (six 1.8.0 (/usr/lib/python2.7/dist-packages), Requirement.parse('six>=1.10'))
您可以通过执行以下操作来修复它:
sudo pip install --ignore-installed six
…在某些平台上看到以下错误
/tmp/pip-build-U8pSsr/cython/Cython/Plex/Scanners.c:4:20: fatal error: Python.h: No such file or directory #include "Python.h" ^ compilation terminated.
您可以通过安装python dev包来修复它。即
sudo apt-get install python-dev