激活 conda 失败(来源 ~/.bashrc)
activating conda fails (sourcing ~/.bashrc)
我在 "Ubuntu 14.04.5 LTS" 上新安装了 Anaconda (Anaconda3-2019.07-Linux-x86_64),但激活安装失败:
source ~/.bashrc
returns Illegal variable name.
cat ~/.bashrc
:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/scientia/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/scientia/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/scientia/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/scientia/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
第一行似乎是这样的原因:__conda_setup="$('/home/scientia/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
我发现我使用的是 tcsh shell,它不允许 .bashrc
.
中使用的语法
正在执行 bash
然后 sourcing 成功了。
如您所见,.bashrc
初始化是 bash 特定的。但是,Conda 也支持 csh/tcsh 的初始化。简直运行
/home/scientia/anaconda3/bin/conda init tcsh
然后重新启动您的 tcsh 会话,现在应该正确配置了 Conda。如果您想查看它添加到 .tcshrc
.
的内容,您可以 运行 带有详细标志 -v
的上述内容
首先,通过这个找到你的shell:
echo $Shell
如果你get:csh,你应该输入:
conda init tcsh
或:./conda init tcsh
在~/anaconda3/bin/
我在 "Ubuntu 14.04.5 LTS" 上新安装了 Anaconda (Anaconda3-2019.07-Linux-x86_64),但激活安装失败:
source ~/.bashrc
returns Illegal variable name.
cat ~/.bashrc
:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/scientia/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/scientia/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/scientia/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/scientia/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
第一行似乎是这样的原因:__conda_setup="$('/home/scientia/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
我发现我使用的是 tcsh shell,它不允许 .bashrc
.
正在执行 bash
然后 sourcing 成功了。
如您所见,.bashrc
初始化是 bash 特定的。但是,Conda 也支持 csh/tcsh 的初始化。简直运行
/home/scientia/anaconda3/bin/conda init tcsh
然后重新启动您的 tcsh 会话,现在应该正确配置了 Conda。如果您想查看它添加到 .tcshrc
.
-v
的上述内容
首先,通过这个找到你的shell:
echo $Shell
如果你get:csh,你应该输入:
conda init tcsh
或:./conda init tcsh
在~/anaconda3/bin/