Ubuntu

Conda Installation Process on Ubuntu

Conda is the environment and package manager for Anaconda. It is a free, open-source software development platform that can be used to create applications for any platform and in any language. It is used to manage the software package’s dependencies and install, operate, and update the software packages. Anaconda includes over 250 pre-installed packages and supports over 7500 more open-source packages from PyPI. It has a CLI (conda) and a GUI (Anaconda Navigator). Anaconda may be used to manage the packages for any programming language, but it is prevalent for managing the Python and R packages. Additional packages can be added to Anaconda. It is compatible with desktop operating systems including Mac, Windows, Linux, etc. The methods of installing Anaconda on Ubuntu are covered in this article.

Prerequisites:

To install Anaconda on Ubuntu, you need the following:

  • A superuser-privileged terminal window or CLI
  • 3GB or more of available disk space

Why Use Conda?

Conda is a popular choice for managing the Python packages because it offers several benefits, including the following:

  • Reproducibility: Conda environments can be easily reproduced which is essential for data science, AI, and machine learning projects.
  • Isolation: Conda environments are separated from one another which helps to prevent the package conflicts.
  • Dependency management: You don’t need to install the packages because Conda manually manages the package dependencies.
  • Performance: Conda packages are pre-compiled which makes them faster to install and run.

Anaconda Installation on Ubuntu

Step 1: Get Anaconda

To get Anaconda, download the installer from the Anaconda website. Open your computer browser and go to “https://www.anaconda.com/products/individual” to download Anaconda.

Scroll down until you reach the Linux section on the Anaconda individual edition page. Then, click on the “Download” button after selecting the required version of Anaconda for your machine.

Step 2: Install Anaconda

After downloading, launch the Ubuntu terminal and go to the directory/folder that contains the Anaconda installation file.

Run the following command if the file is downloaded and stored in your system’s “Downloads” directory:

$ cd ~/Downloads

Then, use the following command to make the Anaconda installation file executable:

$ chmod +x Anaconda3-2023.09-0-Linux-x86_64.sh

It should be noted that the version number may change based on the version that you downloaded. It might be beneficial if you change or use a different filename for the “Anaconda3-2023.09-0-Linux-x86_64.sh” installation file that you downloaded.

Now, execute the command to begin the Anaconda installation.

$ ./Anaconda3-2023.09-0-Linux-x86_64.sh

Replace the version number again with the exact filename of the installation file that you downloaded.

Step 3: Follow the Installation Wizard’s Instructions

After performing the previously mentioned command, you will be prompted to accept the Anaconda license agreement. To proceed, type “yes” and press “Enter”.

After that, you will be requested to pick a location for installation. Since the default location is the most suitable option, press “Enter” to move forward.

After following these steps, Anaconda will be installed on your system.

Step 4: Verify the Anaconda Installation

To check the installation, run the following command:

$ conda list

This shows a list of every package and the Anaconda library installs by default.

As seen in the output, Anaconda is installed successfully.

Step 5: Create and Activate an Isolated Environment

Anaconda allows you to build the isolated environments in which the specified versions of libraries and packages can be installed. This is useful when working on numerous projects with various requirements. This command can be used to create a new environment:

$ conda create --name myenv

Output:

Substitute your preferred environment name in place of “myenv”. Additionally, you can select the release of Python or any other programs that you want to include in this environment.

To make the environment active, execute the following command:

$ conda activate myenv

Output:

Now, in this environment, you can include any package or module.

Step 6: Install the Libraries and Packages

Depending on the needs of your project, you might need to install the extra packages and libraries, even if Anaconda has many of them already included.

To install a specific package, replace <package_name> with the package name. The version number and any additional dependencies that you wish to install alongside the package can also be specified.

Example:

$ conda install numpy

Output:

Step 7: Update Anaconda

Your Anaconda installation should always include the most recent packages and libraries. The command to update Anaconda is as follows:

$ conda update --name base conda

All of the packages and libraries that come with Anaconda by default will be updated. Additionally, you can update specific packages by naming them.

Step 8: Use Pip to Install the Packages

Even though using Conda is an excellent way to manage the Python packages, pip, the built-in Python package manager, may occasionally be required for package installation. In the Anaconda environment, pip can also be used to install the packages:

Substitute “package_name” with the name of the package that you require. You can also specify the version number and any other dependencies that you intend to include with the package.

Example:

$ pip install pandas

Step 9: Create an Environment File

If your Anaconda environment contains many installed packages and libraries, you may wish to make a file to keep track of all the dependencies. You can make an environment file using the following command:

$ conda env export > environment.yml

Output:

Uninstall Anaconda

To permanently delete or uninstall Anaconda from the machine, run this command:

$ rm -rf ~/anaconda3

Your system will no longer have the Anaconda installation directory.

Difference Between Conda, Anaconda, and Miniconda

Conda, Anaconda, and Miniconda are all related to the Python package management.

  • Conda is a package and environment manager for multiple programming languages, including Python and R. It allows you to manage, install, and update the packages and their dependencies in a reproducible and isolated environment.
  • Anaconda is a software distribution that includes Conda and a large collection of pre-installed machine learning and data science packages.
  • Miniconda is a minimal Anaconda distribution that includes Conda and a small set of essential packages.

Conclusion

In this post, we demonstrated how to install Conda on Ubuntu. Additionally, we discussed how to install the packages and libraries, configure the environments, update Anaconda, and remove Anaconda from your machine. You should be able to begin utilizing Anaconda for your data science, ML, and AI projects after reading this article.

About the author

Omar Farooq

Hello Readers, I am Omar and I have been writing technical articles from last decade. You can check out my writing pieces.