每次我尝试在终端中使用
conda
时,都会收到此错误:
zsh: correct 'conda' to '.conda' [nyae]?
我已将
export PATH=$PATH:$HOME/anaconda/bin
添加到我的 .zshrc
和我的 .bash_profile
文件中。
现在,如果我运行
source ~/.bash_profile
它可以工作,但是每次打开新窗口时我都必须运行此命令。有没有办法来解决这个问题?
我遇到了同样的问题,所以我将 coda 初始化代码从 .bashrc 复制到 .zshrc 并且它起作用了。
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/path/to/ur/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/path/to/ur/anaconda3/etc/profile.d/conda.sh" ]; then
. "/path/to/ur/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/path/to/ur/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
如果您正在使用函数,这可能是您的命名约定的问题,请尝试使用不同的名称来命名它,这样它就不会与
conda
本身发生冲突。
您也可以随时使用
conda init $SHELL
,例如conda init zsh
重新初始化 conda env 设置
function init {
# 🌟 If the following line set to conda, it will face the same issue
# 🌟 that's why I changed it to -conda
if [ "$1" = "-conda" ]; then
# 🌟 `conda init zsh` will re-initializing the following sections
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/mu/miniconda/bin/conda' 'shell.zsh' 'hook' 2>/dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/mu/miniconda/etc/profile.d/conda.sh" ]; then
. "/Users/mu/miniconda/etc/profile.d/conda.sh" # commented out by conda initialize
else
export PATH="/Users/mu/miniconda/bin:$PATH" # commented out by conda initialize
fi
fi
unset __conda_setup
# <<< conda initialize <<<
conda activate ${2:-base} # initialize the conda env at the same time
fi
}