8

If you do conda info --envs you get a list of the environments you create in anaconda

Is there a way to do this but to get also the dates of creation of these environments?

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
  • 2
    You might be able to look at the creation date of the folder where the environment is stored – darthbith May 06 '18 at 15:37
  • 1
    I'd also try to get the creation date for the environment-folders, but notice that getting that timestamp may be tricky, depending on your OS: https://stackoverflow.com/a/39501288/1623829 – AllanLRH Jul 15 '18 at 15:44
  • 1
    Found a good one-line answer here: https://stackoverflow.com/a/69109373/6010333 `conda env list | grep -v '^#' | perl -lane 'print $F[-1]' | xargs ls -lrt1d` – MorganStark47 Dec 08 '21 at 11:02

2 Answers2

4

You can try the following steps:

  1. Figure out the root folder of all the environments. You can do this by using conda env list command. This will show a list of environments with their path.

  2. You can check the creation date of the folder corresponding to each environment.

For mac, the root folder for all environments was /anaconda3/envs. Inside that folder, just type ls -ltr.

vishalaksh
  • 2,054
  • 5
  • 27
  • 45
1
envs=`conda env list | tail -n +4 $1`; 
IFS=' '; 
for x in ${envs};
 do read -a res <<< "$x";
 echo $(ls --full-time --no-group -g -d $res);
done

Explanation by lines:

  1. List the environments and skip some of it, in this case you should see if +4 is your number (it should be)
  2. The output of conda env list has a white space as delimiter (this ensures that yours IFS has this separator
  3. Iterate over the output
  4. Read every line and split with the delimiter on IFS
  5. Print the environment's folder info hiding some things, like group, author. And the -d arguments that list directories themselves, not their contents.

Feel free to customize yours or edit this one.

titusfx
  • 1,896
  • 27
  • 36