21700: Install Bundler system-wide in Rails postinst
[arvados.git] / doc / sdk / python / sdk-python.html.textile.liquid
1 ---
2 layout: default
3 navsection: sdk
4 navmenu: Python
5 title: "Installation"
6 ...
7 {% comment %}
8 Copyright (C) The Arvados Authors. All rights reserved.
9
10 SPDX-License-Identifier: CC-BY-SA-3.0
11 {% endcomment %}
12
13 The Python SDK provides access from Python to the Arvados API and Keep, along with a number of command line tools for using and administering Arvados and Keep.
14
15 h2. Installation
16
17 If you are logged in to an Arvados VM, the Python SDK should be installed.
18
19 To use the Python SDK elsewhere, you can install it "from an Arvados distribution package":#package-install or "from PyPI using pip":#pip-install.
20
21 {% include 'notebox_begin_warning' %}
22 As of Arvados 3.0, the Python SDK requires Python 3.8+.
23 {% include 'notebox_end' %}
24
25 h2(#package-install). Install from a distribution package
26
27 This installation method is recommended to make the CLI tools available system-wide. It can coexist with the pip installation method described below.
28
29 First, configure the "Arvados package repositories":../../install/packages.html
30
31 {% assign arvados_component = 'python3-arvados-python-client' %}
32
33 {% include 'install_packages' %}
34
35 The package includes a virtualenv, which means the correct Python environment needs to be loaded before the Arvados SDK can be imported. You can test the installation by doing that, then creating a client object. Ensure your "@ARVADOS_API_HOST@ and @ARVADOS_API_TOKEN@ credentials are set up correctly":{{site.baseurl}}/user/reference/api-tokens.html. Then you should be able to run the following without any errors:
36
37 <notextile>
38 <pre>~$ <code class="userinput">source /usr/lib/python3-arvados-python-client/bin/activate</code>
39 (python-arvados-python-client) ~$ <code class="userinput">python</code>
40 Python 3.7.3 (default, Jul 25 2020, 13:03:44)
41 [GCC 8.3.0] on linux
42 Type "help", "copyright", "credits" or "license" for more information.
43 >>> <code class="userinput">import arvados</code>
44 >>> <code class="userinput">arvados.api('v1')</code>
45 &lt;apiclient.discovery.Resource object at 0x233bb50&gt;
46 </pre>
47 </notextile>
48
49 Alternatively, you can run the Python executable inside the @virtualenv@ directly:
50
51 <notextile>
52 <pre>~$ <code class="userinput">/usr/lib/python3-arvados-python-client/bin/python</code>
53 Python 3.7.3 (default, Jul 25 2020, 13:03:44)
54 [GCC 8.3.0] on linux
55 Type "help", "copyright", "credits" or "license" for more information.
56 >>> <code class="userinput">import arvados</code>
57 >>> <code class="userinput">arvados.api('v1')</code>
58 &lt;apiclient.discovery.Resource object at 0x233bb50&gt;
59 </pre>
60 </notextile>
61
62 After you have successfully tested your installation, proceed to the the "API client overview":api-client.html and "cookbook":cookbook.html to learn how to use the SDK.
63
64 h2(#pip-install). Install from PyPI with pip
65
66 This installation method is recommended to use the SDK in your own Python programs. If installed into a @virtualenv@, it can coexist with the system-wide installation method from a distribution package.
67
68 Note the Python SDK uses @pycurl@ which depends on the @libcurl@ C library.  To build the module you may have to first install additional packages.  On Debian-based distributions you can install them by running:
69
70 <notextile>
71 <pre><code># <span class="userinput">apt install git build-essential python3-dev libcurl4-openssl-dev libssl-dev</span>
72 </code></pre>
73 </notextile>
74
75 Run @python3 -m pip install arvados-python-client@ in an appropriate installation environment, such as a @virtualenv@.
76
77 {% include 'notebox_begin_warning' %}
78 If your version of @pip@ is 1.4 or newer, the @pip install@ command might give an error: "Could not find a version that satisfies the requirement arvados-python-client". If this happens, try @python3 -m pip install --pre arvados-python-client@.
79 {% include 'notebox_end' %}
80
81 You can test the installation by creating a client object. Ensure your "@ARVADOS_API_HOST@ and @ARVADOS_API_TOKEN@ credentials are set up correctly":{{site.baseurl}}/user/reference/api-tokens.html. Then you should be able to run the following without any errors:
82
83 <notextile>
84 <pre>~$ <code class="userinput">python3</code>
85 Python 3.7.3 (default, Jul 25 2020, 13:03:44)
86 [GCC 8.3.0] on linux
87 Type "help", "copyright", "credits" or "license" for more information.
88 >>> <code class="userinput">import arvados</code>
89 >>> <code class="userinput">arvados.api('v1')</code>
90 &lt;apiclient.discovery.Resource object at 0x233bb50&gt;
91 </pre>
92 </notextile>
93
94 After you have successfully tested your installation, proceed to the the "API client overview":api-client.html and "cookbook":cookbook.html to learn how to use the SDK.