Skip to content

Conda

Conda is initialised in your command line by running.

Bash
conda init bash

This adds some startup code to your terminal so that conda will be able to work. You should not need to run this command again.

Default environment directory

By default, conda will try to create environments where the default or base environment exists. Regular users do not have permissions for this directory so we must direct our environments to a location in each users home directory. This is done by adding a few lines to the .condarc file which is where the user configuration for conda is stored.

Edit the file .condarc file using mousepad

Bash
mousepad `/md3_01/<project>/home/<user>/.condarc`

If the file is empty, add the following lines, replacing the username as appropriate. If it is not empty, add the line under the envs_dirs heading, putting it at the top of the list:

Bash
envs_dirs:
  - /md3_01/<project>/home/<user>/envs

Save the file to disk using File > Save.

Image requires alt text

Save the modified `.condarc` file.

Once this has been done, any conda environments you create will be installed into this location. conda environments can then be created as normal and they will be installed to the location specified in the .condarc file.

Create a new conda environment

Conda has many subcommands that allow for the creating, management and removal of environments. The full conda manual is here.

For example, to create a new environment

Bash
conda create -n MyEnv python=3.7

which creates a new environment with the name MyEnv, and installs a fresh copy of your selected Python version with its dependencies (in our case version 3.7).

To activate the new env

Bash
conda activate MyEnv

You can then install packages using conda install or pip install.

Conda Channels

In order to install new software and packages, conda makes use of package "channels". These channels can be broad collections of more recent software (such as conda-forge) that hasn't made into the main conda repository, or be domain specific (e.g. bioconda or astroconda). New channels can typically be added with

Bash
conda config –add channels <channel-name>

Not all packages will be in conda, but conda also contains many non-python tools and packages that users can install (e.g. pip).