Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.


Overview

Conda is an open-source, cross-platform, language-agnostic package manager and environment management system that allows you to quickly install, run, and update packages within your work environment(s).

Here we will cover:

  1. Packages and package managers

  2. Installing conda

  3. Creating a conda environment

  4. Useful conda commands

Prerequisites

ConceptsImportanceNotes
Installing and Running PythonHelpful

Packages and package managers

A Python package is a collection of modules, which, in turn, are essentially Python scripts that contain published functionality. There are Python packages for data input, data analysis, data visualization, etc. Each package offers a unique toolset and may have its own unique syntax rules.

Many geoscience workflows tend to rely on relatively complex collections of Python packages and compiled libraries. Frequent updates to packages can also cause conflicts to arise between incompatible versions. For these reasons, it is often best to create tailored computing environments for each project. Keeping track of package dependencies and versions, and keeping incompatible environments isolated from each other, is the job of a package manager!

You may have encountered a few different package managers in the Python world:

A key advantage of conda over pip is that it manages all types of package requirements, not just Python packages. The most reliable source of up-to-date, interoperable scientific packages are found in the community-maintained conda-forge repository (see below).

Installing conda

We recommend you start by installing Miniforge. This is a specific version of the conda package manager pre-configured to work with the conda-forge package repository—our recommended source for most of the packages you will need.

You can install Miniforge by following the instructions for your machine.

A few reasons why we recommend installing Miniforge:

  1. It’s free, lightweight, and won’t interfere with other installations on your computer.

  2. It encourages you to install only the packages you need in reproducible isolated environments for specific projects. This is generally a more robust way to work with open source tools.

  3. It uses conda-forge as the default channel for packages, which is our recommended way to get up-to-date, interoperable packages.

Once you have conda via the Miniforge installer, the next step is to create an environment and install packages.

Creating a conda environment

A conda environment is an interoperable collection of specific versions of packages or libraries that you install and use for a specific workflow. The conda package manager takes care of dependencies, so everything works together in a predictable way. One huge advantage of using environments is that any changes you make to one environment will not affect your other environments at all, so you are much less likely to “break” something!

To create a new conda environment, type conda create --name and the name of your environment in your terminal, and then specify any packages that you would like to have installed. For example, to install a Jupyter-ready environment called sample_environment, type

conda create --name sample_environment python jupyterlab

Once the environment is created, you need to activate it in the current terminal session (see below).

It is a good idea to create a new environment for every project. Because Python is open source, new versions of the tools are released frequently. Isolated environments help guarantee that your scripts use the same versions of packages and libraries to ensure they run as expected. Similarly, it is best practice to NOT modify your base environment.

Useful conda commands

Some other conda commands that you will find useful include:

You can find lots more information in the conda documentation or this handy conda cheat sheet.


Summary

Conda is a package and environment management system that allows you to quickly install, run, and update packages within your work environment(s). This is important for gathering all of the tools necessary for your workflow.

We recommend installing conda via Miniforge and using it manage packages in your terminal with the conda command.

What’s next?

Additional resources