Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 818
Nic Wanavit Avatar asked Oct 14 '19 02:10

Nic Wanavit


People also ask

What is conda activate environment?

With conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them. Switching or moving between environments is called activating the environment. You can also share an environment file.

How do you find the anaconda environment path?

To export the exact set of paths used by Anaconda, use the command echo %PATH% in Anaconda Prompt. This is needed to avoid problems with certain libraries such as SSL. Show activity on this post. Note that the execution policy of powershell must be set, e.g. using Set-ExecutionPolicy Unrestricted .

Do you have to activate conda environment every time?

Question 1: do i have to activate the conda env every time i open command prompt? No, you do not have to activate conda every time you open CMD. This is simply a matter of choice for the developer.


1 Answers

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
like image 61
Simba Avatar answered Oct 10 '22 13:10

Simba