How To Install the Anaconda Python Distribution on Ubuntu 20.04 [Quickstart]

Introduction

Anaconda is an open-source package manager, environment manager, and distribution of the Python and R programming languages.

This tutorial will guide you through installing the Python 3 version of Anaconda on an Ubuntu 20.04 server. For a more detailed version of this tutorial, with more thorough explanations of each step, please refer to How To Install the Anaconda Python Distribution on Ubuntu 20.04.

Step 1 — Retrieving the Latest Version of Anaconda

From a web browser, find the latest version of Anaconda for Python 3 at the Anaconda Downloads page:

https://www.anaconda.com/distribution/

At the time of writing, the latest version is 2020.02, but you should use a later stable version if it is available.

Step 2 — Downloading the Anaconda Bash Script

Change to the /tmp directory on your Ubuntu 20.04 server as a sudo non-root user.

  • cd /tmp

Use curl to download the link that you copied from the Anaconda website. We’ll output this to a file called anaconda.sh for quicker use.

  • curl https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh --output anaconda.sh

Step 3 — Verifying the Data Integrity of the Installer

We can now verify the data integrity of the installer with cryptographic hash verification through the SHA-256 checksum and the script we named anaconda.sh.

  • sha256sum anaconda.sh
Output
2b9f088b2022edb474915d9f69a803d6449d5fdb4c303041f60ac4aefcc208bb anaconda.sh

You should check the output against the hashes available at the Anaconda with Python 3 on 64-bit Linux page for your appropriate Anaconda version.

Step 4 — Running the Anaconda Script

  • bash anaconda.sh

You’ll receive the following output to review the license agreement by pressing ENTER until you reach the end.

Output
Welcome to Anaconda3 2020.02 In order to continue the installation process, please review the license agreement. Please, press ENTER to continue >>>

When you get to the end of the license, type yes as long as you agree to the license to complete installation.

Step 5 — Completing the Installation Process

Choose the location of your installation or press ENTER to accept the default location.

Output
Anaconda3 will now be installed into this location: /home/sammy/anaconda3 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below [/home/sammy/anaconda3] >>>

At this point, the installation process will continue. Note that it may take some time.

Step 6 — Selecting Options

Once installation is complete, you’ll receive the following output:

Output
... installation finished. Do you wish the installer to initialize Anaconda3 by running conda init? [yes|no] [no] >>>

Type yes so that you can initialize Anaconda3. You’ll receive some output that states changes made in various directories along with a thank you for installing Anaconda.

Step 7 — Activating the Installation

You can now activate the installation by sourcing the ~/.bashrc file:

  • source ~/.bashrc

Once you have done that, you’ll be placed into the default base programming environment.

Step 8 — Testing the Installation

Use the conda command to test the installation and activation:

  • conda list

You’ll receive output of all the packages you have available through the Anaconda installation:

Step 9 — Setting Up Anaconda Environments

It’s best practice to create new environments for each of your projects. To create a Python 3 environment called my_env the syntax is as follows:

  • conda create --name my_env python=3

Press y to verify setup.

You can activate your new environment by typing the following:

  • conda activate my_env

With your environment activated, your command prompt prefix will reflect that you are no longer in the base environment, but in the new one that you just created.

When you’re ready to deactivate your Anaconda environment, you can do so by typing:

  • conda deactivate

Here are links to more detailed tutorials that are related to this guide:

0 Comments

Creative Commons License