anacondacondaminicondaanaconda3

How to get path of conda env from its name?


When I do conda info --envs, I get list of all envs and their locations like this:

# conda environments:
#
base                  *  /Users/mbp/miniconda3
myenv              /Users/mbp/miniconda3/envs/myenv

Is there a way to get the location of myenv environment from command line? May be something like conda info --envs myenv to get

/Users/mbp/miniconda3/envs/myenv

What's the use case?
I want to cache all the environment dependencies in GitHub actions. This has to happen before the environment is activated. If I know the location of the environment, I can cache all the files in it.


Solution

  • conda info --envs | grep -Po 'myenv\K.*' | sed 's: ::g'
    

    This bash command will retrieve all envs from conda and find the line which starts from myenv and give it to the sed command which inturn removes the spaces

    surprisingly it worked for me