X

How to Install Anaconda on Ubuntu 22.04

Spread the love

Anaconda is an open-source environment and package manager, also a distribution of the Python programming language specifically designed for data science and machine learning tasks.

One of the main advantages of Anaconda is its extensive library support. It includes popular libraries such as NumPy, Pandas, SciPy, Matplotlib, scikit-learn, and many others.

These libraries are widely used for numerical computing, data manipulation, visualization, machine learning, and other data-related tasks. Another key feature of Anaconda is its support for creating isolated environments. Environments allow you to create separate Python environments with specific versions of Python and libraries, ensuring project reproducibility and avoiding conflicts between different packages and versions. This feature is particularly useful when working on multiple projects with different requirements.

Prerequisites

  • A server with Ubuntu 22.04 as OS
  • User privileges: root or non-root user with sudo privileges

Step 1. Download the Anaconda installer

To download Anaconda from the anaconda repo, you can use the following command:

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

Please note, at the time of writing this article, the 2023.03-1 was the latest anaconda version available; you can check for the latest version at the anaconda repo.

Now you can rename the installation script to a shorter name, for example, anaconda.sh:

$ mv Anaconda3-2023.03-1-Linux-x86_64.sh anaconda.sh

To check the integrity of this installer file, you can use the following command for hash verification with SHA-256 checksum:

$ sha256sum anaconda.sh

95102d7c732411f1458a20bdf47e4c1b0b6c8a21a2edfe4052ca370aaae57bab anaconda.sh

The installer file is verified; now, you are ready to run the installer.

Step 2. Install Anaconda

To start the anaconda installation, run the command below in the directory where you downloaded the installer:

$ bash anaconda.sh

You will receive this output with several questions, which you should confirm and choose the location where you want to install Anaconda.

Welcome to Anaconda3 20223.03

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

You can press ENTER to continue the installation, next you will have go through the license and approve the license terms with yes:

The next step is to specify the location for the anaconda3 installation, you enter a new location or use the default one.

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] >>>

Once the installation is completed, you can use the following command to activate the installation:

$ source ~/.bashrc

Step 3. Using Anaconda

Anaconda has its own package manager called “conda,” which allows users to install, update, and manage packages and dependencies easily. Conda helps to ensure that all the required libraries and dependencies for a particular project are installed correctly and compatible, thus simplifying the setup process.
To list installed packages, you can type:

$ conda list

To install new Python packages, use conda install and the name of the package:

(base) user@server:$ conda install numpy

You should receive the following output:


Collecting package metadata (current_repodata.json): done
Solving environment: done

Package Plan

environment location: /home/ec2-user/anaconda3

added / updated specs:
- numpy

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
intel-openmp-2023.1.0      |   hdb19cb5_46305        17.1 MB
mkl-2023.1.0               |   h6d00ec8_46342       171.5 MB
mkl-service-2.4.0          |  py310h5eee18b_1          54 KB
mkl_fft-1.3.6              |  py310h1128e8f_1         207 KB
mkl_random-1.2.2           |  py310h1128e8f_1         284 KB
numpy-1.24.3               |  py310h5f9d8c6_1          11 KB
numpy-base-1.24.3          |  py310hb5e798b_1         6.2 MB
tbb-2021.8.0               |       hdb19cb5_0         1.6 MB
------------------------------------------------------------
                                       Total:       197.1 MB

The following NEW packages will be INSTALLED:

blas pkgs/main/linux-64::blas-1.0-mkl
intel-openmp pkgs/main/linux-64::intel-openmp-2023.1.0-hdb19cb5_46305
mkl pkgs/main/linux-64::mkl-2023.1.0-h6d00ec8_46342
mkl-service pkgs/main/linux-64::mkl-service-2.4.0-py310h5eee18b_1
mkl_fft pkgs/main/linux-64::mkl_fft-1.3.6-py310h1128e8f_1
mkl_random pkgs/main/linux-64::mkl_random-1.2.2-py310h1128e8f_1
numpy pkgs/main/linux-64::numpy-1.24.3-py310h5f9d8c6_1
numpy-base pkgs/main/linux-64::numpy-base-1.24.3-py310hb5e798b_1
tbb pkgs/main/linux-64::tbb-2021.8.0-hdb19cb5_0

Proceed ([y]/n)? y

This will install the new conda package. You can also use the pip command to install some python packages or check the already installed python packages with pip list.

You can easily create Anaconda Environments using the following command:

$ conda create --name new-env

To specify which version you want python to be in this conda environment, you can use the command:

$ conda create -n env38 python=3.8

Once the environment has been created, you can activate it with the command:

$ conda activate env38

If you now check the Python version, you will notice that it is the Python 3.8 version, the one you specified previously.

$ python3 --version
Python 3.8.16

You can exit this environment with the command:

$ conda deactivate

Congratulations! You successfully installed Anaconda on Ubuntu 22.04. If you have any difficulties with the installation process, you can contact our technical support, and they will install and configure Anaconda for you. We are available 24/7. All you need to do is sign up for one of our NVMe VPS plans and submit a support ticket.

admin:
Related Post