How Do I Install Conda on the Yens?

We recommend using Anaconda3 modules that are already installed on the Yens.

If you would like to have a personal installation of conda instead of using anaconda modules on the yens, you can download miniconda to your home directory or project directory if you are sharing project space with collaborators.

Installing Miniconda on Yens

Save the following to a file called install_miniconda.sh. Running this script will download miniconda and install it. We also do not let conda change our bash_profile with auto_activate_base false which is a good practice when running conda on a server or HPC clusters.

#!/bin/sh

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

chmod +x Miniconda3-latest-Linux-x86_64.sh

./Miniconda3-latest-Linux-x86_64.sh

conda config --set auto_activate_base false

Run the miniconda install script:

$ sh install_miniconda.sh

You will have to press “ENTER” and space bar through the license agreement, then type “yes” to accept the licence terms. After that choose an install location. If you have ZFS project space, we recommend installing miniconda in your project space rather than your 50 GB home directory which is easy to fill with conda environments and large python package downloads.

Add path to miniconda

Miniconda should now be installed. Let’s add the path to miniconda bin. Modify your bash_profile to include the path:

$ echo 'export PATH=$HOME/miniconda3/bin:$PATH' >> ~/.bash_profile

Source your bash_profile to apply this change:

$ . ~/.bash_profile

Base conda environment

We can test that conda is installed and ready to use by running:

$ which conda 

You should see:

$HOME/miniconda3/bin/conda

where $HOME will be your user home dir or the project space where you installed miniconda.

Then run:

$ conda info -e

to display conda evironments. You will only see base environment. Anaconda environments let you switch between different python versions. The idea is that two python versions (or more) coexist side by side and you can isolate an “environment” for a specific project with a specific python version and all of the necessary python packages with their specific versions living in that environment.

Making a new conda env

Let’s now make a new conda env with python version 3.10 where we will install numpy and pandas packages that our python project requires.

$ conda create -n py310 python=3.10 

After we create the environment, we need to “activate” it which means it will replace the base environment and we will use python packages and python binary living in the activated environment.

$ source activate py310

You need to install all the necessary packages into that environment only once:

$ pip install numpy pandas matplotlib

After you are done working with the environment, “deactivate” it.

$ source deactivate