Conda

How to manage your own Conda installation

It is quite possible that you’ll need functionality, packages or python library versions that are neither provided centrally nor from QIM/3DIM – See PAGE: Python.
In that case managing your own environment might be what you are looking for.

There are plenty of good online resources on how to do this. Here we provide a small guide and some tips using Anaconda/Miniconda on the platform/cluster.

Installing miniconda

  • Download anaconda or miniconda, e.g. from here, (look for the Linux 64-bit Installer)
  • Start a terminal, and navigate to the location of the installer
  • Change permissions on the installer:
  • chmod u+x Miniconda3-*.sh
  • Launch installer from terminal:
  • . /Miniconda3-*.sh or Miniconda3-*.sh
  • Browse through the user agreement, and choose location of installation. During install you’ll be prompted a yes/no for default initialization of conda. Choose no!

The initialization will put the following in the user .bashrc script.
Instead one can simply copy that to a shell script, such that the CONDA environment is NOT automatically initialized upon starting a terminal.

# >>> conda initialize >>>
# !! Contents within this block are managed by ‘conda init’ !!
__conda_setup=”$(‘/home//miniconda3/bin/conda’ ‘shell.bash’ ‘hook’ 2> /dev/null)”
if [ $? -eq 0 ]; then
  eval “$__conda_setup”
else
  if [ -f “/home//miniconda3/etc/profile.d/conda.sh” ]; then
    . “/home//miniconda3/etc/profile.d/conda.sh”
  else
    export PATH=”/home//miniconda3/bin:\$PATH”
  fi
fi
unset __conda_setup
# <<< conda initialize <<<

Creating environment

  • Launch terminal, and make sure you are in the base environment
  • Create new environment
  • conda create –name <\$NAME> …

Check out online guides for managing CONDA environments, adding packages etc.

Store a ‘copy’ for backup/reproducibility

Make a .yml file, such that you can recreate the environment – either somewhere else (e.g. in an other project, or on an ‘external’ desktop – or in case an update breaks something and the you need to recreate the environment.