19926: Flatten structure of PySDK install instructions
[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 As of Arvados 2.2, the Python SDK requires Python 3.6+.  The last version to support Python 2.7 is Arvados 2.0.4.
22
23 h2(#package-install). Option 1: Install from a distribution package
24
25 This installation method is recommended to make the CLI tools available system-wide. It can coexist with the installation method described in option 2, below.
26
27 First, configure the "Arvados package repositories":../../install/packages.html
28
29 {% assign arvados_component = 'python3-arvados-python-client' %}
30
31 {% include 'install_packages' %}
32
33 {% include 'notebox_begin_warning' %}
34 If you are on Ubuntu 18.04, please note that the Arvados packages that use Python depend on the python-3.8 package. This means they are installed under @/usr/share/python3.8@, not @/usr/share/python3@. You will need to update the commands below accordingly.
35 {% include 'notebox_end' %}
36
37 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:
38
39 <notextile>
40 <pre>~$ <code class="userinput">source /usr/share/python3/dist/python3-arvados-python-client/bin/activate</code>
41 (python-arvados-python-client) ~$ <code class="userinput">python</code>
42 Python 3.7.3 (default, Jul 25 2020, 13:03:44)
43 [GCC 8.3.0] on linux
44 Type "help", "copyright", "credits" or "license" for more information.
45 >>> <code class="userinput">import arvados</code>
46 >>> <code class="userinput">arvados.api('v1')</code>
47 &lt;apiclient.discovery.Resource object at 0x233bb50&gt;
48 </pre>
49 </notextile>
50
51 Alternatively, you can run the Python executable inside the @virtualenv@ directly:
52
53 <notextile>
54 <pre>~$ <code class="userinput">/usr/share/python3/dist/python3-arvados-python-client/bin/python</code>
55 Python 3.7.3 (default, Jul 25 2020, 13:03:44)
56 [GCC 8.3.0] on linux
57 Type "help", "copyright", "credits" or "license" for more information.
58 >>> <code class="userinput">import arvados</code>
59 >>> <code class="userinput">arvados.api('v1')</code>
60 &lt;apiclient.discovery.Resource object at 0x233bb50&gt;
61 </pre>
62 </notextile>
63
64 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.
65
66 h2(#pip-install). Option 2: Install with pip
67
68 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.
69
70 Run @pip install arvados-python-client@ in an appropriate installation environment, such as a @virtualenv@.
71
72 Note:
73
74 The SDK uses @pycurl@ which depends on the @libcurl@ C library.  To build the module you may have to first install additional packages.  On Debian 10 this is:
75
76 <pre>
77 $ apt-get install git build-essential python3-dev libcurl4-openssl-dev libssl-dev
78 </pre>
79
80 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 @pip install --pre arvados-python-client@.
81
82 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:
83
84 <notextile>
85 <pre>~$ <code class="userinput">python</code>
86 Python 3.7.3 (default, Jul 25 2020, 13:03:44)
87 [GCC 8.3.0] on linux
88 Type "help", "copyright", "credits" or "license" for more information.
89 >>> <code class="userinput">import arvados</code>
90 >>> <code class="userinput">arvados.api('v1')</code>
91 &lt;apiclient.discovery.Resource object at 0x233bb50&gt;
92 </pre>
93 </notextile>
94
95 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.