More about conda

The environment and package manager of Anaconda

It is highly recommended to use environments for your work. Environments help to isolate your projects from each other, and to create reproducible setups that can include not only a plethora of Python packages, but also binaries and other dependencies. It is also the easiest way to make sure your code will still work several months or years later while having worked on several other projects in the meantime.

Below is a list of common conda commands. For a complete overview of all available commands, see: Command Reference.

Create an environment

conda create -n ita21

Note that this environment is entirely empty. It will not even contain a Python installation. As a consequence, starting an interactive Python interpreter from this environment will fall back to the system Python.

conda activate ita21
which python
/usr/bin/python

It is not a good idea to use the system Python for your work and/or explorations. It is used by your system and should be left alone!

It is therefore a good idea to at least install Python when creating a new environment. So instead of the above, do

conda create -n ita21 python
conda activate ita21
which python
/Users/< ... >/anaconda3/envs/ita21/bin/python

The base environment

Whenever you launch a new command line client (Terminal, Anaconda Prompt, ...) the base environment of your Anaconda installation will be active by default. Think of it as the operating system of you anaconda installation. Leave the base environment alone! Always use a separate environment for your work. You can have as many as you like, with as little or as many installed packages and tools as needed.

The active environment is mentioned in parenthesis at the start of the command line, before the "prompt". The prompt is a sequence of one or more characters indicating "readiness to receive commands". Usually it is one of $, >, %, but it can be anything. Therefore your command line will look something like this.

(base) $

Once you activate an environment, it will be mentioned in parenthesis instead of base.

(base) $ conda activate ita21
(ita21) $

Since the prompt symbol can be different on different systems, to avoid confusion, and also just for simplicity, the prompt and whatever comes before are often omitted in command line instructions.

So instead of this

(ita21) $ ...

You will see this (unless otherwise mentioned)

...

Just to make sure it registers: Leave the base environment alone!

Installing packages

Install packages in a specific environment.

conda -n ita21 install compas compas_cgal compas_view2

Install a package in the active environment (but, remember, not in base).

conda install compas compas_cgal compas_view2

Note that conda packages are made available via channels. conda doesn't look through all channels automatically. It needs to be told which channels to search for available package releases. Arguable the most important channel is conda-forge. To install a package from conda-forge you can specify it via the -c or --channel option.

conda install -c conda-forge compas

To permanently add conda-forge to the list of channels where conda looks for packages, do

conda config --add channnels conda-forge

Remove an environment

conda env remove -n ita21

Note that you can't remove the current environment. Therefore, before removing an environment you must deactivate it.

conda deactivate
conda env remove -n ita21

Alternatively, you can simply remove all packages from an environment.

conda remove -n ita21 --all

Other commands

List all available environments.

conda info --envs

List all installed packages in the active environment.

conda list

List all COMPAS packages in the active environment.

conda list compas

List all COMPAS packages in a specific environment.

conda list compas -n ita21

Last updated