Search code examples
linuxbashanacondaminiconda

Check what conda environment is currently activated


I'm wondering if there is an easy way to check which conda environment is currently activated.

I know you can do conda env list and the active environment will be printed with a *. However, I would like to do this programmatically as an input into an else if statement.

parsing the output of conda env list is rather inconvenient so I hope there is an easier way


Solution

  • When a conda environment is activated, it will export following related environment variables:

    • $CONDA_DEFAULT_ENV, name of current activated env
    • $CONDA_PREFIX, path to the current activate env