blob: f047243f82d8549c302970838b7f4feca1d22af8 [file] [log] [blame]
Masood Malekghassemi451887b2015-03-30 17:44:19 -07001gRPC Python
2===========
3
Masood Malekghassemidfab1192016-02-12 14:48:00 -08004Package for gRPC Python.
Masood Malekghassemi451887b2015-03-30 17:44:19 -07005
Masood Malekghassemidfab1192016-02-12 14:48:00 -08006Installation
Masood Malekghassemi451887b2015-03-30 17:44:19 -07007------------
8
Nathaniel Manistab1faf022017-04-26 20:07:58 +00009gRPC Python is available for Linux, macOS, and Windows.
Masood Malekghassemidfab1192016-02-12 14:48:00 -080010
11From PyPI
12~~~~~~~~~
13
14If you are installing locally...
Masood Malekghassemi451887b2015-03-30 17:44:19 -070015
16::
17
Masood Malekghassemidfab1192016-02-12 14:48:00 -080018 $ pip install grpcio
Masood Malekghassemi451887b2015-03-30 17:44:19 -070019
Masood Malekghassemidfab1192016-02-12 14:48:00 -080020Else system wide (on Ubuntu)...
Masood Malekghassemi451887b2015-03-30 17:44:19 -070021
Masood Malekghassemidfab1192016-02-12 14:48:00 -080022::
Masood Malekghassemi451887b2015-03-30 17:44:19 -070023
Masood Malekghassemidfab1192016-02-12 14:48:00 -080024 $ sudo pip install grpcio
25
Masood Malekghassemid06e9292016-04-27 14:59:17 -070026If you're on Windows make sure that you installed the :code:`pip.exe` component
27when you installed Python (if not go back and install it!) then invoke:
28
29::
30
31 $ pip.exe install grpcio
32
33Windows users may need to invoke :code:`pip.exe` from a command line ran as
34administrator.
35
Masood Malekghassemic0a97a92016-02-22 17:51:02 -080036n.b. On Windows and on Mac OS X one *must* have a recent release of :code:`pip`
37to retrieve the proper wheel from PyPI. Be sure to upgrade to the latest
38version!
39
Masood Malekghassemidfab1192016-02-12 14:48:00 -080040From Source
41~~~~~~~~~~~
42
43Building from source requires that you have the Python headers (usually a
Masood Malekghassemic0a97a92016-02-22 17:51:02 -080044package named :code:`python-dev`).
Masood Malekghassemidfab1192016-02-12 14:48:00 -080045
46::
47
Sree Kuchibhotla2f084ee2016-03-16 16:59:57 -070048 $ export REPO_ROOT=grpc # REPO_ROOT can be any directory of your choice
Mehrdad Afshari976eb7c2017-07-10 21:54:56 +000049 $ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc $REPO_ROOT
Masood Malekghassemidfab1192016-02-12 14:48:00 -080050 $ cd $REPO_ROOT
Masood Malekghassemi0bdc7cc2016-05-05 19:03:43 -070051 $ git submodule update --init
Masood Malekghassemidfab1192016-02-12 14:48:00 -080052
Sree Kuchibhotla2f084ee2016-03-16 16:59:57 -070053 # For the next two commands do `sudo pip install` if you get permission-denied errors
54 $ pip install -rrequirements.txt
55 $ GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .
56
Masood Malekghassemid06e9292016-04-27 14:59:17 -070057You cannot currently install Python from source on Windows. Things might work
58out for you in MSYS2 (follow the Linux instructions), but it isn't officially
59supported at the moment.
Masood Malekghassemi7bee0752016-03-02 14:38:07 -080060
61Troubleshooting
62~~~~~~~~~~~~~~~
63
64Help, I ...
65
66* **... see a** :code:`pkg_resources.VersionConflict` **when I try to install
Sree Kuchibhotla3a0be462016-03-18 09:10:35 -070067 grpc**
Masood Malekghassemi7bee0752016-03-02 14:38:07 -080068
69 This is likely because :code:`pip` doesn't own the offending dependency,
70 which in turn is likely because your operating system's package manager owns
71 it. You'll need to force the installation of the dependency:
72
73 :code:`pip install --ignore-installed $OFFENDING_DEPENDENCY`
Sree Kuchibhotlaffa38f92016-03-17 15:13:08 -070074
75 For example, if you get an error like the following:
76
77 ::
78
79 Traceback (most recent call last):
80 File "<string>", line 17, in <module>
81 ...
82 File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 509, in find
83 raise VersionConflict(dist, req)
84 pkg_resources.VersionConflict: (six 1.8.0 (/usr/lib/python2.7/dist-packages), Requirement.parse('six>=1.10'))
85
86 You can fix it by doing:
87
88 ::
89
90 sudo pip install --ignore-installed six
91
Sree Kuchibhotla3a0be462016-03-18 09:10:35 -070092* **... see the following error on some platforms**
Sree Kuchibhotlaffa38f92016-03-17 15:13:08 -070093
94 ::
95
96 /tmp/pip-build-U8pSsr/cython/Cython/Plex/Scanners.c:4:20: fatal error: Python.h: No such file or directory
97 #include "Python.h"
98 ^
99 compilation terminated.
100
101 You can fix it by installing `python-dev` package. i.e
102
103 ::
104
105 sudo apt-get install python-dev
106