如何避免每次在终端中键入“ source〜/ .bash_profile”命令?

时间:2019-12-17 19:34:40

标签: macos terminal anaconda

我刚刚安装了Anaconda。当我尝试运行命令时,假设说conda --version,我收到以下错误消息:

zsh: command not found: conda

当我输入时:

source ~/.bash_profile

一切正常:

conda --version

conda 4.8.0

但是我每次启动终端时都必须键入命令。

我的.bash_profile看起来像这样:

# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/myusername/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/myusername/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/myusername/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/myusername/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

该如何解决?

系统:macOS

1 个答案:

答案 0 :(得分:1)

source ~/.bash_profile放入~/.zsh

Bash在初始化期间加载.bash_profile,对于zsh,它是.zsh

使用macOS Catalina将默认shell从bash更改为zsh,所以这就是问题所在。