I recently installed Anaconda on my Mac, ran conda init
, and suddenly every new terminal session started with (bash shell)
in my prompt.
When Conda is initialized, it adds this block to .bash_profile
(or .zshrc
if you use zsh):
# >>> 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 <<<
At first, I thought, “Easy! I’ll just comment this out so (base)
won’t appear.”
The Error
When I removed most of that block and only kept this line in Bash Shell:
export PATH="/Users/geoff/anaconda2/bin:$PATH"
I could run conda
as a command, but not conda activate
.
Instead, I got:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
Why This Happen
The conda activate
command isn’t just a binary file it’s a shell function that gets loaded when eval "$__conda_setup"
runs.
If I skip that step, my shell has no idea what “activate” even means.
So yes, removing the init block “fixes” (base)
appearing, but it breaks environment activation entirely.
The Fix That Work for Us
The good news is that I can keep the whole init block and stop Conda from activating base
by default.
The trick is to change Conda’s config:
conda config --set auto_activate_base false
This creates or updates the Conda config file (~/.condarc
or ~/.conda/config.yaml
) with:
auto_activate_base: false
Result
- I can still use
conda activate myenv
. - I can still run all Conda commands.
- I start with my regular shell prompt, no
(base)
clutter.
Toggling Base Activation with a Script
I wanted a quick way to toggle base activation without remembering the commands.
Here’s a small script I wrote:
#!/bin/bash
# toggle_conda_base.sh
# Get current setting
current=$(conda config --show | grep auto_activate_base | awk '{print $2}')
if [ "$current" == "True" ]; then
echo "Disabling auto-activation of base..."
conda config --set auto_activate_base false
else
echo "Enabling auto-activation of base..."
conda config --set auto_activate_base true
fi
Usage:
chmod +x toggle_conda_base.sh
./toggle_conda_base.sh
Summary Table
Action | Command |
---|---|
Disable base auto-activation | conda config --set auto_activate_base false |
Enable base auto-activation | conda config --set auto_activate_base true |
Check current config | conda config --show |
Final Thought
I learned the hard way that conda activate
relies on shell integration, not just PATH
changes.
Instead of hacking the .bash_profile
to remove (base)
, the cleaner approach is telling Conda politely: “Don’t auto-activate base.“