How to install Anaconda scientific computing python distribution on Linux

Anaconda is a distribution of python and other open source packages that are meant to be used for scientific computing. It is frequently used for data science, predictive analytics, and machine learning. Installing Anaconda is the fastest way to have all of the tools for scientific computing readily available to you. It includes the conda package manager, IPython the interactive python shell, the spyder IDE, along with the Project Jupyter interactive web based computational environments: Jupyter Notebook, and JupyterLab.

Anaconda also includes indispensable scientific python packages such as NumPy, pandas, and matplotlib. Such packages could always be manually installed with pip, but having them all pre installed saves a lot of time and effort. Anaconda also includes Anaconda Navigator, a user friendly GUI that serves as a launcher for many of the aforementioned tools and also makes it easy to install and launch optional programs such as RStudio and VS Code. Installing RStudio and installing VS Code could be done independently from Anaconda, but once again, Anaconda streamlines the process of installing multiple packages, saving you a lot of time and effort.

In this tutorial you will learn:

  • How to install Anaconda on Linux
  • How to keep your Anaconda environment up to date.
  • How to search for, install, and remove packages with conda
  • How to clean the package cache to free up disk space with conda
How to install Anaconda scientific computing python distribution on Linux

How to install Anaconda scientific computing python distribution on Linux

Software requirements and conventions used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any GNU/Linux system
Software Anaconda
Other Privileged access to your Linux system as root or via the sudo command is not necessary.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to Install Anaconda on Linux

To install Anaconda, the first step is to navigate to the Anaconda Downloads webpage and select the appropriate installer for your architecture under the Linux section. In this example, we will use the 64-Bit (x86) Installer, as this is most common.
To download this installer on the command line enter the following.

$ wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh


Next, we make the file executable and run it.

$ chmod +x Anaconda3-2020.11-Linux-x86_64.sh
$ ./Anaconda3-2020.11-Linux-x86_64.sh

You will be presented with the following text.

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

Next, press Enter to view the BSD license, then press q to exit the license and move forward with the installation.
You will then be presented with the following text.

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

Type yes then press enter.
Next, you will see the following.

Anaconda3 will now be installed into this location: /home/$USER/anaconda3 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below [/home/$USER/anaconda3] >>>

Press enter to install Anaconda into the default directory in your user’s home directory.
This will install the entire Anaconda distribution which may take some time.
Once it completes you will be presented with the following prompt

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

If you type yes and press enter this essentially adds Anaconda executables to your PATH making them launchable by typing the executable name at the shell rather than it’s full path. This is recommended as it makes launching the programs easier.

You now have a fully functional installation of the Anaconda distribution.
If you start a new instance of your shell then you can launch any of the Anaconda executables by typing their name and pressing enter.
For example, enter any of the following to open the appropriate program.

$ spyder
$ jupyter-lab
$ jupyter-notebook

Alternatively, you can simply type anaconda-navigator and launch those applications from the GUI.

Using the conda package manager

Now that you have Anaconda installed and you are managing your scientific python packages with it, you should periodically keep them up to date with the conda package manager just like you would keep your system up to date with your distribution’s package manager.
To fully update your Anaconda environment enter the following command.

$ conda update --all

You will see a list of packages to be updated followed by this prompt.

Proceed ([y]/n)?


To finalize the update, press y then enter.

Additional packages can be searched for, installed, and removed with conda with the following commands respectively.

$ conda search $packagename
$ conda install $packagename
$ conda remove $packagename

After prolonged use and updating of the Anaconda Distribution you may find that the disk usage of your your ~/anconda3 directory has increased significantly. This is due to the package caches located in ~/anaconda3/pkgs and can be easily cleared with the following command.

$ conda clean --all

You will see a list of package caches to be removed followed by this prompt.

Proceed ([y]/n)?

To remove them, press y then enter. This is a safe process and will not remove the installed executables of the packages, just the tarballs that were used to install them.

Conclusion

In this article we walked through the process of installing the Anaconda scientific computing python distribution on Linux. We briefly examined what it is and why it may be desirable to use it compared to installing scientific python packages manually and independently. We also discussed how to keep the Anaconda environment up to date with the conda package manager. We looked at how to search for, install and remove packages with conda and how to free up disk space by removing the package cache with conda.
The Anaconda Distribution is incredibly easy to install and just as easy to use to manage all of your scientific computing needs.



Comments and Discussions
Linux Forum