What is Conda?
Conda is an open source (BSD licensed), language-independent package manager and environment management system that runs on different operating systems (Windows, macOS and Linux). It was built for Python programs, but can package and distribute software for any language. Conda quickly installs, runs, and updates packages and their dependencies.
In this article, we will explain how to install Conda on Ubuntu.
Conda package and environment manager are included in all versions of Miniconda and Anaconda Repository. We will install Conda with these 2 methods on Ubuntu.
Method-1: Installing Conda with Miniconda
Miniconda is a free minimal installer for conda. Go to Miniconda official download address, copy the download link.
Type the link after the wget command:
foc@ubuntu22:~$ wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh
--2022-12-21 19:48:18-- https://repo.anaconda.com/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.131.3, 104.16.130.3, 2606:4700::6810:8203, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.131.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 76607678 (73M) [application/x-sh]
Saving to: ‘Miniconda3-py39_4.12.0-Linux-x86_64.sh’
Miniconda3-py39_4 100%[=============>] 73.06M 645KB/s in 67s
2022-12-21 19:49:25 (1.08 MB/s) - ‘Miniconda3-py39_4.12.0-Linux-x86_64.sh’ saved [76607678/76607678]
Give execute permission to the downloaded ".sh" file:
foc@ubuntu22:~$ chmod +x Miniconda3-py39_4.12.0-Linux-x86_64.sh
Then run the ".sh" file:
foc@ubuntu22:~$ ./Miniconda3-py39_4.12.0-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 .... Please answer 'yes' or 'no':' Miniconda3 will now be installed into this location: /home/foc/miniconda3 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below [/home/foc/miniconda3] >>> PREFIX=/home/foc/miniconda3 Unpacking payload ... ... Preparing transaction: done Executing transaction: done installation finished. Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no] yes .... ==> 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!
Prefer that conda's base environment be activated on startup, set the auto_activate_base parameter to true:
foc@ubuntu22:~$ conda config --set auto_activate_base True
Upload completed successfully. Version:
(base) foc@ubuntu22:~$ conda -V
conda 4.12.0
Method-2: Installing Conda with Anaconda
Anaconda is the world's most popular open source Python distribution platform. Go to the official download address for the Anaconda installation script and copy the link.
Pull the Anaconda3-2022.10-Linux-x86_64.sh file to your computer with wget:
foc@ubuntu22:~$ wget https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh
--2022-12-22 18:09:12-- https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.131.3, 104.16.130.3, 2606:4700::6810:8303, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.131.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 773428196 (738M) [application/x-sh]
Saving to: ‘Anaconda3-2022.10-Linux-x86_64.sh’
Anaconda3-2022.10 100%[=============>] 737.60M 1.71MB/s in 7m 35s
2022-12-22 18:16:47 (1.62 MB/s) - ‘Anaconda3-2022.10-Linux-x86_64.sh’ saved [773428196/773428196]
Then give execute permission this file
foc@ubuntu22:~$ chmod +x Anaconda3-2022.10-Linux-x86_64.sh
Run the file:
foc@ubuntu22:~$ ./Anaconda3-2022.10-Linux-x86_64.sh
Welcome to Anaconda3 2022.10
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
... Do you accept the license terms? [yes|no] [no] >>> yes ... Preparing transaction: done Executing transaction: | Installed package of scikit-learn can be accelerated using scikit-learn-intelex. More details are available here: https://intel.github.io/scikit-learn-intelex For example: $ conda install scikit-learn-intelex $ python -m sklearnex my_application.py ... done installation finished. Do you wish the installer to initialize Anaconda3 by running conda init? [yes|no] ... modified /home/foc/.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 Anaconda3! =========================================================================== Working with Python and Jupyter is a breeze in DataSpell. It is an IDE designed for exploratory data analysis and ML. Get better data insights with DataSpell. DataSpell for Anaconda is available at: https://www.anaconda.com/dataspell
Anaconda installed, now reboot the system:
foc@ubuntu22:~$ sudo reboot
Then set it to be active on startup:
(base) foc@ubuntu22:~$ conda config --set auto_activate_base true
The conda version that comes with Anaconda:
(base) foc@ubuntu22:~$ conda -V
conda 22.9.0
Update Conda
Updating Conda is very easy. For this, run the following command in terminal:
(base) foc@ubuntu22:~$ conda update conda
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/foc/anaconda3
added / updated specs:
- conda
The following packages will be downloaded:
package | build
---------------------------|-----------------
conda-22.11.1 | py39h06a4308_4 927 KB
conda-package-handling-1.9.0| py39h5eee18b_1 946 KB
conda-repo-cli-1.0.24 | py39h06a4308_0 115 KB
ruamel.yaml-0.17.21 | py39h5eee18b_0 178 KB
ruamel.yaml.clib-0.2.6 | py39h5eee18b_1 140 KB
------------------------------------------------------------
Total: 2.3 MB
The following NEW packages will be INSTALLED:
ruamel.yaml pkgs/main/linux-64::ruamel.yaml-0.17.21-py39h5eee18b_0 None
ruamel.yaml.clib pkgs/main/linux-64::ruamel.yaml.clib-0.2.6-py39h5eee18b_1 None
The following packages will be UPDATED:
conda 22.9.0-py39h06a4308_0 --> 22.11.1-py39h06a4308_4 None
conda-package-han~ 1.9.0-py39h5eee18b_0 --> 1.9.0-py39h5eee18b_1 None
conda-repo-cli 1.0.20-py39h06a4308_0 --> 1.0.24-py39h06a4308_0 None
Proceed ([y]/n)? y
Downloading and Extracting Packages conda-22.11.1 | 927 KB | ############################# | 100% ruamel.yaml-0.17.21 | 178 KB | ############################# | 100% conda-repo-cli-1.0.2 | 115 KB | ############################# | 100% ruamel.yaml.clib-0.2 | 140 KB | ############################# | 100% conda-package-handli | 946 KB | ############################# | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done Retrieving notices: ...working... done
The packages and sizes to be updated are listed, when you give your approval, the update is completed.
Remove Conda
If for some reason you want to uninstall Conda, the steps here should help. First, the following lines are deleted from the user's .bashrc file:
(base) foc@ubuntu22:~$ nano ~/.bashrc
# >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! __conda_setup="$('/home/foc/anaconda3/bin/conda' 'shell.bash' 'hook' 2>> if [ $? -eq 0 ]; then eval "$__conda_setup" else if [ -f "/home/foc/anaconda3/etc/profile.d/conda.sh" ]; then . "/home/foc/anaconda3/etc/profile.d/conda.sh" else export PATH="/home/foc/anaconda3/bin:$PATH" fi fi #unset __conda_setup # <<< conda initialize <<<
Then source the .bashrc file:
(base) foc@ubuntu22:~$ source ~/.bashrc
foc@ubuntu22:~$
Directory selection was made during installation. If no changes are made, directories such as anaconda3/miniconda3 are created in the user's home directory. Delete this directory:
foc@ubuntu22:~$ rm -rf ~/anaconda3
or
foc@ubuntu22:~$ rm -rf ~/miniconda3
No more conda when you type conda in terminal:
foc@ubuntu22:~$ conda
-bash: /home/foc/anaconda3/bin/conda: No such file or directory
Quit the active terminal and re-enter. Or reboot the system:
foc@ubuntu22:~$ sudo reboot
Now when you type in conda you get the following warning:
foc@ubuntu22:~$ conda
conda: command not found
Summary
We explained how to install Anaconda and Miniconda and conda. We did the installation on Ubuntu 22.04. Although it was basically the same installation, miniconda provided faster and less packages to install conda. The choice is yours.
You can get local help with the --help parameter:
(base) foc@ubuntu22:~$ conda --help
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.
References
docs.anaconda.com - Installing on Linux
docs.conda.io - Installing on Linux