Conda
Base Environment
Conda Configuration
Python
Programming Tips

How to stop Conda from activating the base environment by default

Codemia Knowledge Hub ·

Run conda config --set auto_activate_base false. New shell sessions then start with a clean prompt and no environment active until you activate one yourself. This is the official way to turn off automatic activation of base.

The one-line fix

bash
conda config --set auto_activate_base false

Open a new terminal to see the change. The prompt no longer starts with (base).

Verify the setting

bash
conda config --show auto_activate_base

Expected output:

 
auto_activate_base: False

If it still shows True, a system-level config may be overriding yours (see where the setting is stored).

What the setting changes

conda init adds a hook to your shell startup file (.bashrc, .zshrc, etc.). Every new terminal runs that hook, which does two things:

  1. Makes conda commands available in the shell
  2. Activates the base environment

auto_activate_base false disables only step 2. Conda commands still work; you just don't start inside an environment.

Before (default):

 
(base) user@machine ~ $

After:

 
user@machine ~ $

Activate environments when you need them:

bash
conda activate myproject

Where the setting is stored

The setting lives in ~/.condarc, a YAML file in your home directory:

yaml
auto_activate_base: false

You can edit this file directly. conda config just writes to it for you.

When the setting seems to be ignored

Conda reads several config files. To see which ones and in what priority order:

bash
conda config --show-sources

A system-level file such as /etc/conda/.condarc, or an environment-level one, can override your user setting:

bash
1# Example output
2==> /etc/conda/.condarc <==
3auto_activate_base: true
4
5==> /home/user/.condarc <==
6auto_activate_base: false

Here the system config wins. Changing it needs admin access, but you can override it with an environment variable:

bash
export CONDA_AUTO_ACTIVATE_BASE=false

Put that line in .bashrc or .zshrc to make it permanent.

Reverting to the default

To activate base on startup again:

bash
conda config --set auto_activate_base true

Or remove the key from ~/.condarc:

bash
conda config --remove-key auto_activate_base

Removing the key returns to Conda's built-in default, true.

What conda init adds to your shell profile

For Bash, conda init adds a block like this to ~/.bashrc:

bash
1# >>> conda initialize >>>
2# !! Contents within this block are managed by 'conda init' !!
3__conda_setup="$('/home/user/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
4if [ $? -eq 0 ]; then
5    eval "$__conda_setup"
6else
7    if [ -f "/home/user/miniconda3/etc/profile.d/conda.sh" ]; then
8        . "/home/user/miniconda3/etc/profile.d/conda.sh"
9    else
10        export PATH="/home/user/miniconda3/bin:$PATH"
11    fi
12fi
13unset __conda_setup
14# <<< conda initialize <<<

This block makes conda commands available, and it also checks auto_activate_base and activates base when the setting is true. Do not delete or comment out the block to stop base activation. That removes all of Conda's shell integration, and conda activate stops working.

conda init vs auto_activate_base

conda initauto_activate_base
PurposeWire Conda into your shellControl startup environment
Without itconda activate does not workbase is always active
Commandconda init bash (or zsh, fish, etc.)conda config --set auto_activate_base false
ModifiesShell startup file (.bashrc, .zshrc)~/.condarc

If conda is not found in a new terminal, the problem is conda init, not auto_activate_base. Run conda init for your shell first, then set the auto-activate preference. If you switch shells (for example from Bash to Zsh, or install Fish), run conda init zsh or conda init fish separately.

Activating an environment per project instead

Many developers want no environment on startup but automatic activation inside a project directory.

Using direnv

bash
1# Install direnv
2# In your project directory, create .envrc:
3echo 'eval "$(conda shell.bash hook)"' > .envrc
4echo 'conda activate myproject' >> .envrc
5direnv allow

Entering the directory activates the environment, and leaving it deactivates it.

Using an environment-level .condarc

Conda does not read a .condarc from an arbitrary project directory. It does read one from the active environment's root ($CONDA_PREFIX) and from the path in $CONDARC, so you can keep environment settings scoped there:

yaml
# $CONDA_PREFIX/.condarc (the active environment's root)
envs_dirs:
  - /path/to/project/envs

This does not auto-activate anything, but it keeps environment management scoped.

Things that trip people up

  • The current terminal does not change. The setting affects new shell sessions only. Open a new terminal.
  • System-level .condarc overrides. On shared or corporate machines an admin may have set auto_activate_base: true. Check with conda config --show-sources.
  • python now means system Python. With auto-activation off, python in a new terminal is the system interpreter, not a Conda one. Activate an environment first.

Miniforge and Mamba

The same setting works with Miniforge and Mamba:

bash
conda config --set auto_activate_base false
# or
mamba config --set auto_activate_base false

All Conda-compatible tools share the ~/.condarc file.


Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms