Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export all created conda environments

Tags:

conda

I know how to export a specific conda environment:

conda activate myenv
conda env export > myenv.yaml

But how can I automatically export all created conda environments (in separate yaml files, whose name corresponds to the name of the environment)?

like image 828
Tom de Geus Avatar asked Mar 21 '26 22:03

Tom de Geus


1 Answers

You don't need to activate the environment. conda env export accepts the argument -n <env name> which you can combine with a for loop over the output of conda list:

for env in $(conda env list | cut -d" " -f1); do 
   if [[ ${env:0:1} == "#" ]] ; then continue; fi;
   conda env export -n $env > ${env}.yml
done
like image 93
FlyingTeller Avatar answered Mar 24 '26 15:03

FlyingTeller