I recently installed anaconda2 on my Mac. By default Conda is configured to activate the base environment when I open a fresh terminal session.
I want access to the Conda commands (i.e. I want the path to Conda added to my $PATH
which Conda does when initialised so that's fine).
However I don't ordinarily program in python, and I don't want Conda to activate the base environment by default.
When first executing conda init
from the prompt, Conda adds the following to my .bash_profile
:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/geoff/anaconda2/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/geoff/anaconda2/etc/profile.d/conda.sh" ]; then
. "/Users/geoff/anaconda2/etc/profile.d/conda.sh"
else
export PATH="/Users/geoff/anaconda2/bin:$PATH"
fi
# fi
unset __conda_setup
# <<< conda initialize <<<
If I comment out the whole block, then I can't activate any Conda environments.
I tried to comment out the whole block except for
export PATH="/Users/geoff/anaconda2/bin:$PATH"
But then when I started a new session and tried to activate an environment, I got this error message:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
This question (and others like it) are helpful, but doesn't ultimately answer my question and is more suited for linux users.
To be clear, I'm not asking to remove the (base)
from my $PS1
I'm asking for Conda not to activate base when I open a terminal session.
You can set "python. terminal. activateEnvironment": false in your settings to deactivate activation of your environment.
It's not that, but instead that you can't remove the base environment, which is what the --all flag does. You can't uninstall all packages in base because that's where the conda executable lives. Instead, what you want to do is uninstall all user-installed packages.
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.
There're 3 ways to achieve this after conda
4.6. (The last method has the highest priority.)
Use sub-command conda config
to change the setting.
conda config --set auto_activate_base false
In fact, the former conda config
sub-command is changing configuration file .condarc
. We can modify .condarc
directly. Add following content into .condarc
under your home directory,
# auto_activate_base (bool)
# Automatically activate the base environment during shell
# initialization. for `conda init`
auto_activate_base: false
Set environment variable CONDA_AUTO_ACTIVATE_BASE
in the shell's init file. (.bashrc
for bash, .zshrc
for zsh)
export CONDA_AUTO_ACTIVATE_BASE=false
To convert from the
condarc
file-based configuration parameter name to the environment variable parameter name, make the name all uppercase and prependCONDA_
. For example, conda’salways_yes
configuration parameter can be specified using aCONDA_ALWAYS_YES
environment variable.
The environment settings take precedence over corresponding settings in .condarc
file.
conda config --describe
I have conda 4.6 with a similar block of code that was added by conda. In my case, there's a conda configuration setting to disable the automatic base activation:
conda config --set auto_activate_base false
The first time you run it, it'll create a .condarc
in your home directory with that setting to override the default.
This wouldn't de-clutter your .bash_profile
but it's a cleaner solution without manual editing that section that conda manages.
The answer depends a little bit on the version of conda
that you have installed. For versions of conda >= 4.4, it should be enough to deactivate
the conda environment after the initialization, so add
conda deactivate
right underneath
# <<< conda initialize <<<
To disable auto activation of conda base environment in terminal:
conda config --set auto_activate_base false
To activate conda base environment:
conda activate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With