How to Install Anaconda on Ubuntu 18.04

In this tutorial, we will show you how to install Anaconda Python on Ubuntu 18.04, as well as some short tutorials on how to set up Anaconda environments.

Anaconda is a large and powerful platform of the Python and R programming languages. It provides a lot of tools that can be used in areas such as Jupiter Notebook, Pandas, and so on. Additionally, it is used for data processing, machine learning, and predictive analytics.

Anaconda provides a lot of popular python packages and package manager called ‘condaSome of the popular anaconda packages are numpy, scipy, jypiter, nltk, etc… You will get all of these packages with anaconda instead of installing a plain version  of python and using pip for managing and installing these packages.

Let’s get started with the installation.

Prerequisites

  • For the purposes of this tutorial, we will use an Ubuntu 18.04 VPS.
  • Full SSH root access or a user with sudo privileges is also required.

Step 1: Connect via SSH and Update

Connect to your server via SSH as the root user using the following command:

ssh root@IP_ADDRESS -p PORT_NUMBER

Remember to replace “IP_ADDRESS” and “PORT_NUMBER” with your server’s respective IP address and SSH port number.

Before starting with the installation, you will need to update your system packages to their latest versions. It’s easy to do, and it won’t take more than a few minutes.

You can do this by running the following command:

sudo apt-get update
sudo apt-get upgrade

Once the updates are completed, we can move on to the next step.

Step 2: Install Anaconda

Before installing and downloading the Anaconda installer script, we should visit Anaconda Download page and check if there is a new version of Anaconda. The latest stable version of Anaconda at the time of this article being written is version 2019.03.

Now we will change to the tmp directory and here is where we will download the installation script. The download command for version 2019.03 has been written for you:

cd /tmp
curl -O https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh

Step 3: Run the Install Script

Now we will start the Anaconda installation process by running the installation script:

bash Anaconda3-2019.03-Linux-x86_64.sh

You should see the following output:

Welcome to Anaconda3 2019.03

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue

We will press the [ENTER] key to continue the installation. The next step is to then agree to and approve the license terms:

Output:
Do you accept the license terms? [yes|no]

Type yes, then press the [ENTER] key to submit your answer. Now we should choose the installation location.

Output:
Anaconda3 will now be installed into this location:
/root/anaconda3

- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below

We will choose the default path location /root/anaconda3. Press the [ENTER] key to continue with the installation. The installation will take some time – once it is completed, you will be prompted with the following output:

Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]

We will type yes so that we can use the conda command. You should be presented with the following output:

For changes to take effect, close and re-open your current shell.

If you'd prefer that conda's base environment not be activated on startup,
set the auto_activate_base parameter to false:
conda config --set auto_activate_base false

Thank you for installing Anaconda3!

Next, we will activate the Anaconda installation and load the initial path which we added previously. To activate the Anaconda installer, run the following command:

source ~/.bashrc

We can verify the Anaconda installation by running the following command:

conda info

The following output should be given:

active environment : base
active env location : /root/anaconda3
shell level : 1
user config file : /root/.condarc
populated config files :
conda version : 4.6.11
conda-build version : 3.17.8
python version : 3.7.3.final.0
base environment : /root/anaconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/linux-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /root/anaconda3/pkgs
/root/.conda/pkgs
envs directories : /root/anaconda3/envs
/root/.conda/envs
platform : linux-64
user-agent : conda/4.6.11 requests/2.21.0 CPython/3.7.3 Linux/2.6.32-042stab131.1 ubuntu/18.04 glibc/2.23
UID:GID : 0:0
netrc file : None
offline mode : False

You now have a working copy of Anaconda on your Ubuntu 18.04 VPS. The next step can help you learn to use this new software.

Step 4: Creating an Anaconda Environment

Anaconda virtual environments help us to organize unique Python versions for each environment. This allows us to set up a different version of Python for each environment. Let’s create an environment using the latest version of Python.

Run the following command to create the environment (You can change ‘virt_env‘ to any name that you like, as well as the Python version):

conda create --name virt_env python=3

Once it is created you can activate it with the following command:

conda activate virt_env

If you want to deactivate it for any reason, just run this command:

conda deactivate

That’s all there is to it – in this tutorial, we learned how to install Anaconda on Ubuntu 18.04, as well as how to create virtual environments. There are a lot more capabilities that Anaconda offers that we haven’t covered in this tutorial – this is why we suggest reading the documentation in order to be able to fulfill the server’s full potential.

Of course, you don’t have to install Anaconda Python on an Ubuntu 18.04 VPS if you use one of our Python VPS Hosting Solutions, in which case you can simply ask our expert Linux admins to install Anaconda on Ubuntu 18.04 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to install Anaconda on Ubuntu 18.04,  please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

The new version of the article available here: How to install Anaconda on Ubuntu 20.04.

Leave a Comment