Cyberithub

How to Install Miniconda on Ubuntu 20.04 LTS (Focal Fossa)

Advertisements

In this article, I will take you through the steps to install Miniconda on Ubuntu 20.04 LTS (Focal Fossa). Miniconda is a free minimal installer for conda. It is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others. Miniconda contains conda package manager and python. Once it is installed, you can use conda command to install any other packages and environments. More on official website. It can be easily installed in Windows, Linux and macOS based systems. Here we will see the steps to install Miniconda on Ubuntu 20.04 LTS.

How to Install Miniconda on Ubuntu 20.04 LTS (Focal Fossa)

How to Install Miniconda on Ubuntu 20.04 LTS (Focal Fossa)

Also Read: How to Install virtualenv on Ubuntu 20.04 LTS (Focal Fossa)

Advertisements

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

b) You should have sudo or root access to run privileged commands.

Advertisements

c) You should have apt and wget utility available in your System.

 

Step 2: Update Your Server

First you need to update all the packages in your System by using sudo apt update command as shown below. This will sync your System packages with the latest available versions from Ubuntu repo.

Advertisements
cyberithub@ubuntu:~$ sudo apt update
[sudo] password for cyberithub:
Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
Hit:2 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu focal InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:4 https://dl.google.com/linux/chrome/deb stable InRelease [1,811 B]
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:7 https://dl.google.com/linux/chrome/deb stable/main amd64 Packages [1,093 B]
Get:8 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [1,739 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [725 kB]
............................................................

If any of the system packages needs to be upgraded then run sudo apt upgrade command as well. Since in our case all the packages are already upgraded to the latest versions, it is not showing any further packages to upgrade.

cyberithub@ubuntu:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
pypy-lib
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

 

Step 3: Download Miniconda

To install miniconda, you need to first download the latest Miniconda script by using below curl command.

Advertisements
cyberithub@ubuntu:~$ curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o Miniconda3-latest-Linux-x86_64.sh
% Total    % Received  % Xferd  Average Speed Time   Time    Time     Current
                                Dload Upload Total   Spent   Left     Speed
100 73.0M 100 73.0M    0     0  5318k      0 0:00:14 0:00:14 --:--:-- 4751k

 

Step 4: Set Execute Permission

To run Miniconda script, you need to make it executable by setting execute permission using chmod +x  Miniconda3-latest-Linux-x86_64.sh command as shown below.

cyberithub@ubuntu:~$ chmod +x Miniconda3-latest-Linux-x86_64.sh

 

Step 5: Install Miniconda

Then to install miniconda you need to either run ./Miniconda3-latest-Linux-x86_64.sh or bash Miniconda3-latest-Linux-x86_64.sh as shown below. During the installation, it will ask you to Press Yes few times and set the installation path. By default it will be installed in your home location.

cyberithub@ubuntu:~$ bash Miniconda3-latest-Linux-x86_64.sh

Welcome to Miniconda3 py39_4.12.0

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
======================================
End User License Agreement - Miniconda
======================================

Copyright 2015-2022, Anaconda, Inc.

All rights reserved under the 3-clause BSD License:

This End User License Agreement (the "Agreement") is a legal agreement between you and Anaconda, Inc. ("Anaconda") and governs your use of Miniconda.

Subject to the terms of this Agreement, Anaconda hereby grants you a non-exclusive, non-transferable license to:

* Install and use the Miniconda,
..........................................
no change /home/cyberithub/miniconda3/condabin/conda
no change /home/cyberithub/miniconda3/bin/conda
no change /home/cyberithub/miniconda3/bin/conda-env
no change /home/cyberithub/miniconda3/bin/activate
no change /home/cyberithub/miniconda3/bin/deactivate
no change /home/cyberithub/miniconda3/etc/profile.d/conda.sh
no change /home/cyberithub/miniconda3/etc/fish/conf.d/conda.fish
no change /home/cyberithub/miniconda3/shell/condabin/Conda.psm1
no change /home/cyberithub/miniconda3/shell/condabin/conda-hook.ps1
no change /home/cyberithub/miniconda3/lib/python3.9/site-packages/xontrib/conda.xsh
no change /home/cyberithub/miniconda3/etc/profile.d/conda.csh
modified /home/cyberithub/.bashrc

==> 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 Miniconda3!

 

Step 6: Export PATH

Since Miniconda installed in a path which by default is not visible to the system so to make it visible across the system you need to export the location to PATH environment variable as shown below.

cyberithub@ubuntu:~$ export PATH=$PATH:/home/cyberithub/miniconda3/bin

Same can be verified by using echo $PATH command as shown below. But this will be a temporary change. To make it permanent, you need to add the above entry in ~/.profile or ~./bashrc file.

cyberithub@ubuntu:~$ echo $PATH
/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/cyberithub/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/cyberithub/miniconda3/bin

 

Step 7: Check Version

To test the installation, you can run conda --version command as shown below.

cyberithub@ubuntu:~$ conda --version
conda 4.12.0

 

Step 8: Using Miniconda

Now that Miniconda is installed, you can use conda command to install any packages and create environments. For example, here we are installing a package called boto3 using conda install boto3 command as shown below.

cyberithub@ubuntu:~$ conda install boto3
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

environment location: /home/cyberithub/miniconda3

added / updated specs:
- boto3


The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
boto3-1.24.28              |   py39h06a4308_0        114 KB
botocore-1.27.28           |   py39h06a4308_0        4.6 MB
ca-certificates-2022.07.19 |       h06a4308_0        124 KB
certifi-2022.9.14          |   py39h06a4308_0        155 KB
conda-4.14.0               |   py39h06a4308_0        915 KB
cytoolz-0.11.0             |   py39h27cfd23_0        350 KB
jmespath-0.10.0            |     pyhd3eb1b0_0        22 KB
openssl-1.1.1q             |       h7f8727e_0        2.5 MB
python-dateutil-2.8.2      |     pyhd3eb1b0_0        233 KB
s3transfer-0.6.0           |   py39h06a4308_0        105 KB
toolz-0.11.2               |     pyhd3eb1b0_0        49 KB
------------------------------------------------------------
Total: 9.2 MB
........................................

 

Step 9: Check all the available options

You can check all the options available with conda command using conda -h command as shown below.

cyberithub@ubuntu:~$ conda -h
usage: conda [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
command
clean Remove unused packages and caches.
compare Compare packages between conda environments.
config Modify configuration values in .condarc. This is modeled after the git config command. Writes to the user .condarc file
(/home/cyberithub/.condarc) by default.
create Create a new conda environment from a list of specified packages.
help Displays a list of available conda commands and their help strings.
info Display information about current conda install.
init Initialize conda for shell interaction. [Experimental]
install Installs a list of packages into a specified conda environment.
list List linked packages in a conda environment.
package Low-level conda package utility. (EXPERIMENTAL)
remove Remove a list of packages from a specified conda environment.
uninstall Alias for conda remove.
run Run an executable in a conda environment.
search Search for packages and display associated information. The input is a MatchSpec, a query language for conda packages. See examples below.
update Updates conda packages to the latest compatible version.
upgrade Alias for conda update.

Leave a Comment