Skip to content

Using Conda in a Research Space

Conda can be used in a research space to share environments with your research group or students in your class. This makes reproducibility and teaching easier.

Note

This page assumes familiarity with conda from our Using conda guide.

Creating the environment

To create an environment in a research space, first make sure you are set to the correct group by following the instructions on our group change page.

  1. Create the environment in the research space with the command:

    conda create --prefix /mnt/research/<your research space>/envs/<environment name> <other conda commands and packages>
    

    This will create the environment in a directory called envs in the root of the research space. Modify the path as needed for your research space structure.

    A specific example command is

    conda create --prefix /mnt/research/helpdesk/envs/plotting-tools matplotlib
    

    which would install an environment called plotting-tools in the helpdesk research space, and install the matplotlib package and its dependencies.

  2. Modify your .condarc file to add the path of your environments directory with the command:

    conda config --append envs_dirs <path to your research space environment>
    

    For the example in step 1, this would be

    conda config --append envs_dirs /mnt/research/helpdesk/envs
    
  3. Verify that the environment is detected with the command

    conda env list
    

    and for the example from step 1 you would get the output

    output
    # conda environments:
    #
    # * -> active
    # + -> frozen
    plotting-tools           /mnt/research/helpdesk/envs/plotting-tools
    base                     /opt/software-current/2023.06/x86_64/generic/software/Miniforge3/25.11.0-1
    

    and then you can activate the environment as normal using its name.

  4. Modify the environment as necessary to meet your needs.

  5. Optional: prevent others from modifying the environment by changing the write permissions on the environment directory. The command would be

    chmod -R g-w <path to the environment>
    

    which for the example from step 1 would be

    chmod -R g-w /mnt/research/helpdesk/envs/plotting-tools