Terminal base prefix problem after installing Anaconda

question

Recently, I wanted to train a small model for use, so I installed Anaconda | Individual Edition on macOS , and chose the graphical interface installation (64-Bit Graphical Installer). The whole process went smoothly, and the next step was enough.

However, after the installation, I found that a base appeared in the prefix of my terminal command line, like this:

(base) -> ~

This is very speechless.

reason

Guess the reason should be that Anaconda injected scripts into the shell configuration file after installation. Because I use zsh, the open .zshrcfile is visible:

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

But in order to ensure the normal use of Anaconda, this script must not be deleted.

solve

Found such a configuration in the official document Using the .condarc conda configuration file :

Change command prompt (changeps1)
When using conda activate, change the command prompt from $PS1 to include the activated environment. The default is True.

EXAMPLE:

changeps1: False

Then we only need to modify ~/.condarcthe file, after adding the content as follows:

channels:
  - defaults
changeps1: False

Then refresh it:

source ~/.condarc

Notice:

When I modified it for the first time, I found that there was no .condarcsuch file, which is very embarrassing! The solution is to start the Anaconda-Navigator application at least once, and the rc configuration file will be generated.

Guess you like

Origin blog.csdn.net/ysy950803/article/details/119899200