Issue
I created four different versions of conda virtual environments
(envs) for image processing tasks. Each env includes GDAL
and OpenCV
, and some subset of related libs and dependencies. I want to cull my list of image processing envs down to the most recently created one, which will have the most complete set of the libs I use. But I don't remember the order I created the envs.
Is there a way to see the creation date of individual envs or perhaps a list of creation dates for all of my conda envs?
UPDATE
Here is the output of the command suggested by @Timur Shtatland
$ conda env list -v -v -v | grep -v '^#' | perl -lane 'print $F[-1]' | xargs ls -lrt1d
$ miniconda3/envs/opencv2_imgproc
$ miniconda3/envs/GDAL_OSGEO_env
Solution
Conda history
files
Aside from file/folder dates, Conda also records the history of all environment changes in the conda-meta/history
file relative to each environment folder, so that could also be consulted. All entries begin with a date stamp (==> YYYY-MM-DD HH:MM:SS <==
), so assuming the first entry corresponds with env creation, one could do something like
#!/bin/bash
for env_hist in path/to/envs/*/conda-meta/history; do
env_prefix=$(dirname $(dirname $env_hist))
echo "$(head -n1 $env_hist) $env_prefix"
done | sort
to print something like
==> 2020-09-28 16:12:49 <== path/to/envs/pymc39
==> 2020-11-08 18:15:26 <== path/to/envs/bioc_3_12
==> 2020-11-22 17:19:08 <== path/to/envs/snakemake_5_29
==> 2021-01-23 00:08:33 <== path/to/envs/pymc3_11
==> 2021-01-23 00:12:53 <== path/to/envs/jupyter
==> 2021-03-09 22:50:38 <== path/to/envs/multiqc
==> 2021-03-24 13:20:07 <== path/to/envs/grayskull
==> 2021-04-05 23:40:01 <== path/to/envs/snakemake_6_1
Answered By - merv