20259: Add documentation for banner and tooltip features
[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 2.2, the Python SDK requires Python 3.6+.  The last version to support Python 2.7 is Arvados 2.0.4.
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 {% include 'notebox_begin_warning' %}
36 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.
37 {% include 'notebox_end' %}
38
39 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:
40
41 <notextile>
42 <pre>~$ <code class="userinput">source /usr/share/python3/dist/python3-arvados-python-client/bin/activate</code>
43 (python-arvados-python-client) ~$ <code class="userinput">python</code>
44 Python 3.7.3 (default, Jul 25 2020, 13:03:44)
45 [GCC 8.3.0] on linux
46 Type "help", "copyright", "credits" or "license" for more information.
47 >>> <code class="userinput">import arvados</code>
48 >>> <code class="userinput">arvados.api('v1')</code>
49 &lt;apiclient.discovery.Resource object at 0x233bb50&gt;
50 </pre>
51 </notextile>
52
53 Alternatively, you can run the Python executable inside the @virtualenv@ directly:
54
55 <notextile>
56 <pre>~$ <code class="userinput">/usr/share/python3/dist/python3-arvados-python-client/bin/python</code>
57 Python 3.7.3 (default, Jul 25 2020, 13:03:44)
58 [GCC 8.3.0] on linux
59 Type "help", "copyright", "credits" or "license" for more information.
60 >>> <code class="userinput">import arvados</code>
61 >>> <code class="userinput">arvados.api('v1')</code>
62 &lt;apiclient.discovery.Resource object at 0x233bb50&gt;
63 </pre>
64 </notextile>
65
66 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.
67
68 h2(#pip-install). Install from PyPI with pip
69
70 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.
71
72 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 you can do this by running:
73
74 <pre>
75 $ apt-get install git build-essential python3-dev libcurl4-openssl-dev libssl-dev
76 </pre>
77
78 Run @python3 -m pip install arvados-python-client@ in an appropriate installation environment, such as a @virtualenv@.
79
80 {% include 'notebox_begin_warning' %}
81 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@.
82 {% include 'notebox_end' %}
83
84 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:
85
86 <notextile>
87 <pre>~$ <code class="userinput">python3</code>
88 Python 3.7.3 (default, Jul 25 2020, 13:03:44)
89 [GCC 8.3.0] on linux
90 Type "help", "copyright", "credits" or "license" for more information.
91 >>> <code class="userinput">import arvados</code>
92 >>> <code class="userinput">arvados.api('v1')</code>
93 &lt;apiclient.discovery.Resource object at 0x233bb50&gt;
94 </pre>
95 </notextile>
96
97 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.