If you use a compute cluster and you use
conda, the default location for your
conda environments will be in your home directory. This can be annoying for a couple reasons:
- Your home directory might have a storage quota
- Collaborators won't have access to your environments
Fortunately, it's pretty easy to migrate your setup to a new directory (like a lab share).
Export (and delete) existing environments
For each environment you want to export it's as simple as
conda activate my_environ, followed by
conda env export > my_environ.yml and
conda remove --name my_environ --all
conda is always changing how this works, but doing something like this worked for me. Make sure to 1. back up your
line like and 2. remove anything else conda related you find in either of those files:
.bash_profile contains something like:
if [ -f ~/.bashrc ]; then . ~/.bashrc fi
you'll want to put the following in
.bashrc, otherwise you'll want to put it in your
#conda activate #. /project2/xinhe/software/miniconda3/etc/profile.d/conda.sh # added by Miniconda3 4.5.12 installer # >>> conda init >>> # !! Contents within this block are managed by 'conda init' !! __conda_setup="$(CONDA_REPORT_ERRORS=false '/project2/xinhe/software/miniconda3/bin/conda' shell.bash hook 2> /dev/null)" if [ $? -eq 0 ]; then \eval "$__conda_setup" else if [ -f "/project2/xinhe/software/miniconda3/etc/profile.d/conda.sh" ]; then . "/project2/xinhe/software/miniconda3/etc/profile.d/conda.sh" CONDA_CHANGEPS1=false conda activate base else \export PATH="/project2/xinhe/software/miniconda3/bin:$PATH" fi fi unset __conda_setup # <<< conda init <<< #put the root conda environment first echo "$PATH"|grep -vq "^/project2/xinhe/software/miniconda3/bin" && export PATH="/project2/xinhe/software/miniconda3/bin:$PATH"
Log off and then log in again, and make sure that
which conda looks like
then reinstall each of your conda environments:
conda env create -f my_environ.yml
You'll want to make sure that
~/.conda/environments.txt contains the paths to your environments in their new directories and not the old ones.