How to remove (base) from terminal prompt after updating conda

BashTerminalAnacondaCondaMiniconda

Bash Problem Overview


After updating miniconda3, whenever I open a terminal it shows "(base)" in front of my username and host.

In this answer post https://askubuntu.com/a/1113206/315699 it was suggested to use

conda config --set changeps1 False

To remove it.

But that would remove the indication for any conda environment. I would like to remove it only for the base one, so that I can maintain it always active and have access to its python and installed packages without having to always see this (base) taking up space.

Bash Solutions


Solution 1 - Bash

That's because conda's base environment is activated on startup.

To set the auto_activate_base parameter to false, type:

conda config --set auto_activate_base false


Edited 2021/09/09:

If you are facing the exact same situation as the OP, that you are using conda to manage environments, and wanted to make (base) environment looks no different to system environment in terminal, check @merv 's answer for the procedures. Note that the prompt string is stored in a certain special variable, depending on the shell you are using, so check the documentation of your shell if it does not work for you.

If you want to use the system environment and not using conda at all, my original answer was the solution for you.

Thanks to @merv and @Neinstein for pointing out in the comments.

Solution 2 - Bash

Use the base env's activation hook

For each env, any scripts in the etc/conda/activate.d directory will be executed post-activation (likewise etc/conda/deactivate.d scripts for deactivation). If you add a script to remove the (base), similar to @ewindes suggestion, you'll get the behavior you desire.

I had to create this directory for base, which is just the root of your Anaconda/Miniconda folder. E.g.,

mkdir -p miniconda3/etc/conda/activate.d

Then made a simple file in there (e.g., remove_base_ps1.sh) with one line:

PS1="$(echo "$PS1" | sed 's/(base) //') "

If you are using zsh, use this instead.

PROMPT=$(echo $PROMPT | sed 's/(base) //')

Launching a new shell then does not show (base), and deactivating out of nested envs also takes care of the PS1 change.

Note: You must add quotes around $PS1 if you want to preserve ending spaces.

Solution 3 - Bash

By default, auto_activate_base is set to True when installing anaconda. To check this, run:

$ conda config --show | grep auto_activate_base
auto_activate_base: True

To set it False

conda config --set auto_activate_base False

and vice-versa.

Note, if changeps1 is kept False, it will hide (env) completely, and in case you want to show (env) only when it's activated, you can set changeps1 to True:

conda config --set changeps1 True

> Setting changeps1 to False will hide (env) even if the env is activated and will keep hiding (base) even after auto_activate_base is set to True.

Solution 4 - Bash

You could add a command to your .bashrc to remove the "(base)" string from PS1:

PS1=$(echo $PS1 | sed 's/(base)//')

Solution 5 - Bash

If you are a macOS user and recently faced such issue. here is the solution. Just open terminal then type..

> conda deactivate

This solution worked for me. As previously I tried some stuffs with anaconda python.

Solution 6 - Bash

For me, what worked was:

conda config --set changeps1 false 

Solution 7 - Bash

on Debian system, after

conda config --set auto_activate_base false

don't forget in order for effects to take place in the terminal without reloading gnome

bash --login

and verify the status of the flag

conda config --show | grep auto_activate_base

Solution 8 - Bash

if you are using any destro of Linux this command will work for you,

conda config --set auto_activate_base false

than

conda deactivate

Solution 9 - Bash

Simply comment out all lines in ~/.bashrc, except the environment variable:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
#__conda_setup="$('/home/<user>/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
#if [ $? -eq 0 ]; then
#    eval "$__conda_setup"
#else
#    if [ -f "/home/<user>/anaconda3/etc/profile.d/conda.sh" ]; then
#        . "/home/<user>/anaconda3/etc/profile.d/conda.sh"
#    else
        export PATH="/home/<user>/anaconda3/bin:$PATH"
#    fi
#fi
#unset __conda_setup
# <<< conda initialize <<<

Solution 10 - Bash

for conda 4.12.0 (under WOS) the following worked (where all the previous answers -these included- didn't do the trick):
in your activate.bat file (mine was at ~/miniconda3/Scripts/activate.bat), change the line:

@REM This may work if there are spaces in anything in %*
@CALL "%~dp0..\condabin\conda.bat" activate %*

into

@REM This may work if there are spaces in anything in %*
@CALL "%~dp0..\condabin\conda.bat" deactivate

this line chage/modification doesn't work in the section (of the activate.bat file):

@if "%_args1_first%"=="+" if NOT "%_args1_last%"=="+" (
		@CALL "%~dp0..\condabin\conda.bat" activate
		@GOTO :End
)

maybe because it depends on how your miniconda3 (Anaconda Prompt) executable is set up: %windir%\System32\cmd.exe "/K" some-path-to\miniconda3\Scripts\activate.bat some-path-to\miniconda3 (in my case).

caveat: updating conda overwrites this (activate.bat) file; so one has to modify the above line as many times as needed/updated. not much of a deal-breaker if you ask me.

Solution 11 - Bash

When using conda and vscode. conda activates the virtual environment in your project if you have one and if not conda and vscode create one for you called base.

to deactivate it, use:

conda deactivate

Solution 12 - Bash

On my macOS Catalina installation, I just ran conda config --set env_prompt "". That removed it for me.

Solution 13 - Bash

Maybe it will be because of source active

I had this similar issue when I was doing this in flask server and I activated and forgot to deactivate virtual environment.

So go to the folder that virtual environment is active and type

source deactivate

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHomero EsmeraldoView Question on Stackoverflow
Solution 1 - BashYokissaView Answer on Stackoverflow
Solution 2 - BashmervView Answer on Stackoverflow
Solution 3 - BashmontiView Answer on Stackoverflow
Solution 4 - BashewindesView Answer on Stackoverflow
Solution 5 - BashcodexaxorView Answer on Stackoverflow
Solution 6 - BashCecília AssisView Answer on Stackoverflow
Solution 7 - BashArtem KozlenkovView Answer on Stackoverflow
Solution 8 - BashManishyadavView Answer on Stackoverflow
Solution 9 - BashTiminView Answer on Stackoverflow
Solution 10 - BashManuel FView Answer on Stackoverflow
Solution 11 - BashKhyar AliView Answer on Stackoverflow
Solution 12 - BashMattView Answer on Stackoverflow
Solution 13 - BashBinwin Viju LatentViewView Answer on Stackoverflow