Skip to content

Instantly share code, notes, and snippets.

@andrea137
Created November 8, 2018 10:45
Show Gist options
  • Save andrea137/fb0e7083e2acaa9bb323aab0254702ee to your computer and use it in GitHub Desktop.
Save andrea137/fb0e7083e2acaa9bb323aab0254702ee to your computer and use it in GitHub Desktop.
A simple script to export all the conda/Anaconda environments at once. Useful for example to backup or to move conda/Anaconda from one directory to another (https://docs.anaconda.com/anaconda/user-guide/tasks/move-directory/)
#!/usr/bin/env bash
. $HOME/miniconda3/etc/profile.d/conda.sh
mkdir conda_env_backups
cd conda_env_backups
conda info --envs | awk 'NR>2 {print $1}' > tmp_env_names
while read in; do
conda activate "$in"
conda env export > $in.yml
conda deactivate
done < tmp_env_names
rm tmp_env_names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment