< All Topics
Print

Conda

Conda is a language-agnostic package manager that operates across multiple platforms and enables users the installation and management of packages from both the Anaconda repository and the Anaconda Cloud

Its packages are in binary form. It means that they are pre-compiled, executable files ready to be installed and run on a system, as opposed to the source code, which would require a pre-compilation. Binaries can be optimized for various OSs, making installing and running software easier without worrying about compatibility issues.

This package manager was created to address complex package management challenges faced by Devs and data scientists. Over time, it has evolved into a widely-used package manager for various programming languages, including Python, R, Ruby, Lua, Scala, Java, JavaScript, C/C++, Fortran, and more.[3] 

Conda vs. Pip

Conda and pip are package managers typically perceived as synonymous, helping Devs to run commands. Despite having some similarities in functionality, these two tools were designed for distinct purposes.

Pip enables users to easily install, upgrade, remove packages, and manage dependencies. It integrates with the Python Package Index (PyPI) and provides a way to connect to other package repositories.

On the other hand, Conda is an open-source and language-agnostic package manager that allows users to install and manage Conda packages. These packages are not limited to Python but also programming languages like C, C++, or R.[4]

The following table compares these packages, highlighting the differences and the input method.

TaskConda package and environment manager commandPip package manager command
Install a packageconda install $PACKAGE_NAMEpip install $PACKAGE_NAME
Update a packageconda update –name $ENVIRONMENT_NAME $PACKAGE_NAMEpip install –upgrade $PACKAGE_NAME
Update package managerconda update condaLinux/macOS: pip install -U pip Win: python -m pip install -U pip
Uninstall a packageconda remove –name $ENVIRONMENT_NAME $PACKAGE_NAMEpip uninstall $PACKAGE_NAME
Create an environmentconda create –name $ENVIRONMENT_NAME pythonX
Activate an environmentconda activate $ENVIRONMENT_NAME*X
Deactivate an environmentconda deactivateX
Search available packagesconda search $SEARCH_TERMpip search $SEARCH_TERM
Install package from specific sourceconda install –channel $URL $PACKAGE_NAMEpip install –index-url $URL $PACKAGE_NAME
List installed packagesconda list –name $ENVIRONMENT_NAMEpip list
Create requirements fileconda list –exportpip freeze
List all environmentsconda info –envsX
Install other package managerconda install pippip install conda
Install Pythonconda install python=x.xX
Update Pythonconda update python*X
Source: Conda

If you want to learn more about the various commands available in Conda, check this Conda Cheat Sheet.

Quick Installation Guide

The Conda package is included in all versions of Anaconda Python Distribution and Miniconda. If you want to install Anaconda, follow these instructions:

  1. Access the Anaconda website.
  2. Click on the Products button and select Anaconda Distribution.
  3. Download the installer at the bottom of the website according to your OS (Windows, Linux, or macOS). Here you can find old versions.
  4. Run the *.exe file and accept the installation terms.
  5. Configure the installation settings to suit your requirements.

Note: Miniconda provides a convenient way to set up a minimal installation that consists of only the essential components. This lightweight installation method is helpful for those who want to save disk space and only install the necessary components for their project. 

Install Anaconda Python Distribution on Windows 11.
Install Anaconda Python Distribution on Ubuntu 22.04.1.

Conda Fundamentals

Installing Packages

Conda packages are designed to be cross-platform and compatible with the Anaconda Python Distribution, ensuring that you can use them on any operating system, including Windows, macOS, and Linux. 

Either way, installing packages is a straightforward process. For example, run the “conda list” command to display all the packages installed on your system.

conda list
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0            py39haa95532_0
aiohttp                   3.8.1            py39h2bbff1b_1
aiosignal                 1.2.0              pyhd3eb1b0_0
alabaster                 0.7.12             pyhd3eb1b0_0
anaconda                  2022.05                  py39_0
anaconda-client           1.9.0            py39haa95532_0
anaconda-navigator        2.1.4            py39haa95532_0
anaconda-project          0.10.2             pyhd3eb1b0_0
anyio                     3.5.0            py39haa95532_0
appdirs                   1.4.4              pyhd3eb1b0_0
argon2-cffi               21.3.0             pyhd3eb1b0_0
argon2-cffi-bindings      21.2.0           py39h2bbff1b_0
arrow                     1.2.2              pyhd3eb1b0_0
astroid                   2.6.6            py39haa95532_0
…

If you’re looking for another package, the Anaconda Web Navigator provides an easy way to discover what’s available. For example, to install the Flask package, run the following command in your terminal or Anaconda Prompt:

conda install -c anaconda flask

However, not all packages are available in the Conda repository (e.g., sty); in that case, you’ll need to look it up in the PyPI repository.

In addition, Anaconda gives developers the freedom to choose between different IDEs, including Jupyter Notebook, Spyder, JupyterLab, and more. When using Jupyter Notebook, users must employ the “!pip” command in a code cell. The “!” symbol denotes the characteristic format to run commands. To install the matplotlib package, use:

!pip install matplotlib

Once the installation is complete, you have to import the package.

import numpy as np

Virtual Environments

Conda’s versatility extends beyond package management, as it also serves as a virtual environment manager. It means you don’t have to switch to another manager if you need a package requiring a different Python version. With a few simple commands, you can easily create a different environment to run that specific version of Python.

For Linux distributions, the “(base)” environment is automatically set in the terminal. You can check this using the following command.

conda config --show | grep auto_activate_base

To deactivate the environment, you can use the “False” flag.

conda config --set auto_activate_base False
source ~/.bashrc

To reactivate the “(base)” environment, use the “True” flag.

conda config --set auto_activate_base True
source ~/.bashrc

For users who want to create a new environment, Conda provides a straightforward way by typing the command:

conda create –name ENVIRONMENT_NAME python=3.10

To activate the environment, use

conda activate ENVIRONMENT_NAME

To deactivate the environment, use

conda deactivate

Finally, to list the available environments in your system, use

conda env list

Note: Windows users who have installed Anaconda can employ the commands described in this article. These commands perfectly match with Linux distributions method.

Highlights

Project Background

  • Project: conda.io
  • Author: Authors that have made at least one contribution.
  • Initial Release: 
  • Type: Package Management System
  • License: Berkeley Source Distribution (BSD)
  • Contains: command-line interface, distributions of python.
  • Language: Python, R, Ruby, Lua, Scala, Java, JavaScript, C/C++, Fortran, and more.
  • GitHub: link
  • Runs On: OS-agnostic
  • Twitter: /pypi

Main Features

  • It can be used on Windows, macOS, and Linux, making it a versatile tool.
  • It helps users manage packages and dependencies.
  • It enables the creation of working environments, allowing users to have different packages and dependencies for different projects.
  • It is an open-source project with a large and active community that contributes to its development and supports its users.
  • It can be integrated with other tools and platforms, such as Jupyter Notebook, PyCharm, and Visual Studio Code.

Prior Knowledge Requirements

  • Users should understand how to navigate the file system and run commands from the terminal or command prompt.
  • Users should have a basic understanding of Python or another programming language.
  • Users should know how to create and manage virtual environments and how they are used in Python.

Community Benchmarks

  • 5,100 Stars
  • 1,300 Forks
  • 389+ Code contributors
  • Source: GitHub

Releases

  • 23.1.0 (1-2023): Bug fixes. e.g., Detect CUDA driver version in subprocess.
  • 22.11.0 (11-30-2022): Enhancements and Bug fixes. e.g., Improve CLI warning.
  • 22.9.0 (9-20-22): Enhancements and Bug fixes, and switch to the CalVer versioning system.
  • 4.14.0 (8-3-2022): Enhancements and Bug fixes. e.g., Implementation of a new rename subcommand.
  • 4.13.0 (5-19-2022): Enhancements and Bug fixes. e.g., Introducing “clean –logfiles” to remove logfiles generated by libmamba-solver.
  • Source: releases.

References

[1] GitHub.

[2] Anaconda website

[3] Documentation.

[4] Anaconda blog post.

Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
Please Share Your Feedback
How Can We Improve This Article?
Table of Contents
Scroll to Top