In this article, we cover how to install Anaconda in Ubuntu 22.04 release.
Introduction
Anaconda is one of the most popular distributions of R and Python programming languages. The distribution provides us with the tools that are required for machine learning applications, data science, etc. Though it comes with a set of pre-installed packages. Despite this, for extended functionality, we can also install additional packages.
Applications like JupyterLab, Jupyter Notebook, Spyder, etc. are available as default through Anaconda Navigator.
Note: The following operations require Administrative Rights. Contact your System Administrator if you don’t have the necessary rights.
Installation Prerequisites
There are certain packages that you may have to install before installing the Anaconda distribution in Ubuntu. But, first update the standard Ubuntu repository. So, open a terminal:
sudo apt update
The packages that you may have to install are:
sudo apt install libxss1 libegl1-mesa libxcomposite1 libxrandr2
and,
sudo apt install libxrandr2 libxcursor1 libasound2 libxi6 libxtst6 libgl1-mesa-glx
Important: If you are installing it on a Virtual Machine then ensure that you have sufficient disk space. You would require at least 5GB of disk space.
Download Package
Before we proceed, download the required Anaconda package from the official website.
https://www.anaconda.com/download
Use the Download button to install the required package: Anaconda3-2023.09-0-Linux-x86_64.sh
Install Anaconda in Ubuntu
First, we have to make the package executable. This can be done through chmod command-line utility.
chmod +x Anaconda3-2023.09-0-Linux-x86_64.sh
Now, issue the following command in the terminal:
bash Anaconda3-2023.09-0-Linux-x86_64.sh
It is worth mentioning here that, the package version would be different for you. So, make changes to the above command accordingly. To continue with the installation process it would prompt us to review the License Agreement. At this stage, Press the Enter key to continue.
Go through the License terms, if you agree then enter yes.
Thereafter, it would prompt us whether we want to continue installing the package in a pre-defined location or someplace else.
Press the Enter key if you want to install Anaconda at the default location. If you want to install the package to some other location then, enter the location here.
Lastly, it prompts us whether we want Anaconda3 to get initialized by the installer by running conda init. Enter yes/no here.
Once done, we get the message that Anaconda has been successfully installed.
Launch Anaconda in Ubuntu
We can launch Anaconda Navigator from the terminal itself. Issue the following:
anaconda-navigator
How to update Anaconda?
It is important to regularly update any package we install. Either we can update Anaconda to the latest version or to a specific version. First, to update Anaconda to the latest version, issue the following commands in the terminal:
conda update conda conda update anaconda
On the other hand, if we want the package to get updated to a specific version:
conda update conda conda install anaconda=VERSION-NUMBER
Here, VERSION-NUMBER could be of the form: 2023.09 or 2023.07
Additional Info:
In this section, we talk about how to uninstall the Anaconda distribution. As we didn’t install it through the repository, therefore, we can’t use apt (Advanced Packaging Tool) to uninstall the package.
If, for some reason, you chose to uninstall the Anaconda distribution then, install the following package:
conda install anaconda-clean
Thereafter run it:
anaconda-clean
It prompts us before deleting necessary files. Follow onscreen instructions. This would do two things:
Firstly, it creates a .anaconda_backup directory in our Home directory. As the name suggests, contains all the critical files and directories as backup here.
Secondly, our existing projects directory stays as it is. There are no changes made during the uninstall process.
Now, remove the relevant Anaconda entries from .bashrc file in the Home directory and the directories where our package was installed.
Conclusion
However, the package isn’t available through the standard Ubuntu repository. Still, the installation of Anaconda distribution is pretty straightforward. All we have to do is: install the necessary package from the standard Ubuntu repository. These are required by our Anaconda distribution for proper functioning. Then, install the required package from the official website of Anaconda and follow the steps described above.