Table of Contents
In this article, I will take you through the steps to install Anaconda 3 on Ubuntu 20.04 LTS (Focal Fossa). Anaconda is a distribution of the Python and R programming languages for scientific computation, machine learning and artificial intelligence. It is quite popular among Data Scientists, Python Programmers and Researchers. It's rich set of scientific libraries makes it a favorable choice for performing scientific and research activity. It is currently available for almost all the Linux distributions. Here we will see the steps to install Anaconda 3 on Ubuntu 20.04 LTS System in great detail.
How to Install Anaconda 3 on Ubuntu 20.04 LTS (Focal Fossa)
Also Read: Solved "ModuleNotFoundError: No module named matplotlib"
Step 1: Prerequisites
a) You should have a running Ubuntu 20.04 LTS
System.
b) You should have sudo
or root
access to run privileged commands.
c) You should have apt, sha256sum
and wget
utility available in your System.
Step 2: Update Your System
Always update the system cache with the latest available package information and updates from all the enabled repositories by using apt update
command. This will help system download any missing package updates. If any of the packages needs to be upgraded then run apt upgrade
command as well.
root@cyberithub:~# apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:5 https://dl.google.com/linux/chrome/deb stable InRelease
Get:6 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,750 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [637 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [278 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [391 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [944 B]
Get:11 http://in.archive.ubuntu.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [9,588 B]
Get:12 http://in.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.8 kB]
Get:13 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [40.7 kB]
Get:14 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [66.5 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,464 B]
............................................
Step 3: Download Anaconda
You need to go to official website and download the latest installer by using any of the file transfer utility like wget
as shown below. It will download the installer in the current working directory. You can also use -q
flag to switch off the below output and download the installer quietly.
root@cyberithub:~# wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
--2022-05-01 11:05:21-- https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 2606:4700:8d73:2d97:4ad7:83:6810:8203, 104.16.131.3, 104.16.130.3
Connecting to repo.anaconda.com (repo.anaconda.com)|2606:4700:8d73:2d97:4ad7:83:6810:8203|:443... failed: Connection timed out. install anaconda 3
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.131.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 608680744 (580M) [application/x-sh]
Saving to: ‘Anaconda3-2021.11-Linux-x86_64.sh’
Anaconda3-2021.11-Linux-x86_64.sh 100%[============================================================================>] 580.48M 13.2MB/s in 41s
2022-05-01 11:08:14 (14.2 MB/s) - ‘Anaconda3-2021.11-Linux-x86_64.sh’ saved [608680744/608680744]
Step 4: Verify Installer hashes
Once the installer is downloaded you can verify the hashes by using below sha256sum
command.
root@cyberithub:~# sha256sum Anaconda3-2021.11-Linux-x86_64.sh
fedf9e340039557f7b5e8a8a86affa9d299f5e9820144bd7b92ae9f7ee08ac60 Anaconda3-2021.11-Linux-x86_64.sh
Step 5: Install Anaconda
In the next step, you can start the Anaconda installation using bash Anaconda3-2021.11-Linux-x86_64.sh
command as shown below. During the installation, it will prompt you for confirmation in few of the places.
root@cyberithub:~# bash Anaconda3-2021.11-Linux-x86_64.sh
Welcome to Anaconda3 2021.11
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
===================================
End User License Agreement - Anaconda Individual Edition
===================================
Copyright 2015-2021, Anaconda, Inc.
.......................................................................
==> 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!
===========================================================================
Working with Python and Jupyter notebooks is a breeze with PyCharm Pro,
designed to be used with Anaconda. Download now and have the best data
tools at your fingertips.
PyCharm Pro for Anaconda is available at: https://www.anaconda.com/pycharm
During the installation, it will also ask you to choose in case you want to initialize the conda. Type yes
to initialize or else type no
.
.................................................
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> yes
no change /root/anaconda3/condabin/conda
no change /root/anaconda3/bin/conda
no change /root/anaconda3/bin/conda-env
no change /root/anaconda3/bin/activate
no change /root/anaconda3/bin/deactivate
no change /root/anaconda3/etc/profile.d/conda.sh
no change /root/anaconda3/etc/fish/conf.d/conda.fish
no change /root/anaconda3/shell/condabin/Conda.psm1
no change /root/anaconda3/shell/condabin/conda-hook.ps1
no change /root/anaconda3/lib/python3.9/site-packages/xontrib/conda.xsh
no change /root/anaconda3/etc/profile.d/conda.csh
modified /root/.bashrc
...................................
Step 6: Activate the Installation
You don't have to restart your terminal session for the changes to take effect. You can simply run source ~/.bashrc
command to activate the installation from the same terminal session.
root@cyberithub:~# source ~/.bashrc
(base) root@cyberithub:~#
Step 7: Check Info
To check complete information about Anaconda installation, you can use conda info
command as shown below.
(base) root@cyberithub:~# conda info
active environment : base
active env location : /root/anaconda3
shell level : 1
user config file : /root/.condarc
populated config files :
conda version : 4.10.3
conda-build version : 3.21.5
python version : 3.9.7.final.0
virtual packages : __linux=5.13.0=0
__glibc=2.31=0
__unix=0=0
__archspec=1=x86_64
base environment : /root/anaconda3 (writable)
conda av data dir : /root/anaconda3/etc/conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/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.10.3 requests/2.26.0 CPython/3.9.7 Linux/5.13.0-40-generic ubuntu/20.04.4 glibc/2.31
UID:GID : 0:0
netrc file : None
offline mode : False
Step 8: List Installed Packages
If you want to check the list of installed packages then use conda list
command as shown below.
(base) root@cyberithub:~# conda list
# packages in environment at /root/anaconda3:
#
# Name Version Build Channel
_ipyw_jlab_nb_ext_conf 0.1.0 py39h06a4308_0
_libgcc_mutex 0.1 main
_openmp_mutex 4.5 1_gnu
alabaster 0.7.12 pyhd3eb1b0_0
anaconda 2021.11 py39_0
anaconda-client 1.9.0 py39h06a4308_0
anaconda-navigator 2.1.1 py39_0
anaconda-project 0.10.1 pyhd3eb1b0_0
anyio 2.2.0 py39h06a4308_1
...........................
Step 9: Update Anaconda
If you want to update Anaconda then you need to run conda update conda
command as shown below.
(base) root@cyberithub:~# conda update conda Collecting package metadata (current_repodata.json): done Solving environment: done ## Package Plan ## environment location: /root/anaconda3 added / updated specs: - conda The following packages will be downloaded: package | build ---------------------------|----------------- conda-4.12.0 | py39h06a4308_0 14.5 MB conda-package-handling-1.8.1| py39h7f8727e_0 889 KB ------------------------------------------------------------ Total: 15.3 MB The following packages will be UPDATED: conda 4.10.3-py39h06a4308_0 --> 4.12.0-py39h06a4308_0 conda-package-han~ 1.7.3-py39h27cfd23_1 --> 1.8.1-py39h7f8727e_0 Proceed ([y]/n)? y Downloading and Extracting Packages conda-package-handli | 889 KB | ################################################################################################################## | 100% conda-4.12.0 | 14.5 MB | ################################################################################################################## | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done
Step 10: Uninstall Anaconda 3
Once you are done using Anaconda 3 then you can choose to uninstall Anaconda 3 by following below steps.
a) Remove Anaconda 3 directory
In the first step you need to remove anaconda3 directory by using rm -rf ~/anaconda3
command as shown below.
(base) root@cyberithub:~# rm -rf ~/anaconda3/
b) Edit .bashrc
Then open .bashrc
file using nano editor and remove below lines. Then save the file using Ctrl+X
.
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/root/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/root/anaconda3/etc/profile.d/conda.sh" ]; then
. "/root/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/root/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
c) Remove hidden directory
You can also remove hidden .conda
directory from the User's home location using rm -rf ~/.conda
command as shown below.
(base) root@cyberithub:~# rm -rf ~/.conda
d) Reload the Bash Shell
Finally refresh the bash shell using source ~/.bashrc
command to reflect the recent changes.
(base) root@cyberithub:~# source ~/.bashrc
root@cyberithub:~#