My question is not about changing the .bashrc
file to append source activate env
because it does the same same task. I have no problem writing an extra line of code everytime I use the environment but the problem is that when I deactivate, it switches it to (base)
back again. How can I stop switching to make the (env)
as my default environmenr rather than (base)
so that when I deactivate
, it comes directly to my regular working??
I am using Ubuntu 18
.
Advertisement
Answer
Currently there does not seem to be a “default environment” setting for conda, but I think you can get the behaviour you want with nested activation of conda environments, or “stacked” environments.
You can either do this explicitly or implicitly by changing the conda config. Both assumes that you already have (env)
activated somehow (either manually or adding it to .bashrc
).
Explicitly:
conda activate --stack new_env
. The next time you doconda deactivate
, this should take you back to your previous environment rather than(base)
.Implicitly:
conda config --set auto_stack 5
(should be greater than 0, it is how many nested levels you want)- Now if you do
conda activate new_env
, then it behaves as if it was called asconda activate --stack new_env
.
If you don’t care about the base environment at all, you can disable automatic activation of it by conda config --set auto_activate_base false
.
The --stack
option has been available since conda 4.6.0.