Ubuntu登陆后卡住||Your shell has not been properly configured to use 'conda activate'

Ubuntu服务器一种登陆后卡死的情况

今天通过ssh登陆机器后,一直卡在Last login [Time],无法输入命令。初步定位原因为服务器资源被其他用户耗尽
用ctrl+c可以强制进入命令行,但没有进入base环境,输入conda activate后报错

Your shell has not been properly configured to use 'conda activate'

其他ubuntu自带的命令正常,推测是bash过程中conda未能初始化,打开 ~/.bashrc

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

发现可能是conda_setup被ctrl+c中断导致conda的path没有被正确export,
将上述内容注释掉

打开 ~/.bashrc ,结尾添加

source activate

重新登陆,问题修复;如果仍然在login后卡死,ctrl+c后手动进行source以激活conda环境。

治标不治本的方法,但是配合screen还是挺好用的。

你可能感兴趣的:(Ubuntu登陆后卡住||Your shell has not been properly configured to use 'conda activate')