Using Python on Scientific Computing Linux Clusters with Conda

Scientific Computing (SciC) Linux Clusters is the Linux compute cluster for research.
 
Conda is a package manager providing Python and many associated scientific libraries.
Anaconda is popular distribution of conda that includes a large number of packages from Anaconda curated repositories. License is required to acess Anaconda or managed repositories (including the popular "defaults" channel). Please refer to Anaconda FAQ for explanation of Anaconda licensing and instructions on requesting a license.
 
Conda is also available as a module on ErisTwo with miniforge distribution. Miniforge is an open-source distribution that doesn't include access to licensed Anaconda channels. You don't need an Anaconda license to use miniforge, but you are limited to open-source package channels, such as conda-forge and bioconda.

Loading and Initializing Conda with miniforge

To use Python on SciC Linux Clusters, load the miniforge3 module. Type the command below at the $ prompt on the SciC Linux Clusters command line

   $ module load miniforge3

Creating and activating environments

To create a new environment, you can use the conda create command :

$ conda create -n <env-name> [packages to be installed]

This will create a new environment with the given name in the default location, which is $HOME/.conda/envs. For example, to create a new environment called 'test-python that will have python 3.8 installed:

$ conda create -n test-python-3.8 python=3.8

If you would like to create an environment in a location other than the default, use the -p flag instead of the -n flag to specify a path:

$ conda create -p path/to/envs/<env-name> [packages to be installed]

To view the environments you have created:

$ conda env list

Finally, to activate your conda environment:

$ conda activate <env-name>

Once activated, you can now start installing using all the python packages included with Anaconda.

Adding additional packages

Use the conda install tool to get python packages. When using the conda install tool, it is helpful to include which channel you would like the package installed from. Different conda channels offer different builds of each package. Do not use "defaults" channel unless you purchased Anaconda license. More information on using channels can be found here.

(env-name) $ conda install -c <channel-name> package_name

You could also install a package with pip:

   (env-name) $ pip install --user package_name

Using the "--user" option ensures that the package is installed in your home directory. Without this option you would get an error message as permissions will not allow pip to install in the SciC Linux Clusters software repository. We recommend to use pip installation only in cases when conda installation is not available.

Creating virtual environments

Refer to this FAQ and the online documentation for more information on setting up virtual environments

 

Go to KB0028044 in the IS Service Desk

Related articles