出现的问题
问题1:终端命令前面有base
1、命令行执行:(取消默认加载环境)
conda config --set auto_activate_base false
此时没有了(base)标志,但是输入python默认的是python2.7.这就是问题2
解决:在anaconda安装时选择的初始化,.bashrc中的对应文件如下
#作用应该是一打开终端就初始化conda环境
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/s/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/s/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/s/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/s/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
把这段注释掉,如下
#不让conda自己初始化
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
#__conda_setup="$('/home/s/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
#if [ $? -eq 0 ]; then
# eval "$__conda_setup"
#else
# if [ -f "/home/s/anaconda3/etc/profile.d/conda.sh" ]; then
# . "/home/s/anaconda3/etc/profile.d/conda.sh"
# else
# export PATH="/home/s/anaconda3/bin:$PATH"
# fi
#fi
#unset __conda_setup
# <<< conda initialize <<<
此时没有了(base)标志,但是输入python默认的是python2.7.这就是问题2
问题2:消除base后,在终端输入python时发现,此时python的版本不是对应anaconda版本里的
解决:在.bashrc文件末尾加上anaconda的路径,如下
#不让conda自己初始化
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
#__conda_setup="$('/home/s/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
#if [ $? -eq 0 ]; then
# eval "$__conda_setup"
#else
# if [ -f "/home/s/anaconda3/etc/profile.d/conda.sh" ]; then
# . "/home/s/anaconda3/etc/profile.d/conda.sh"
# else
# export PATH="/home/s/anaconda3/bin:$PATH"
# fi
#fi
#unset __conda_setup
# <<< conda initialize <<<
#显示conda下的Python
export PATH="/home/s/anaconda3/bin:$PATH"
执行
source .bashrc
输入python默认输出conda中的Python了。
参考:ubuntu系统,anaconda3安装后,命令行界面打开默认进入base环境解决办法
参考:ubuntu18.04安装anaconda后终端出现base字样
linux下激活与退出anaconda
不推荐
激活
source activate
退出
source deactivate
推荐
激活
conda activate
退出
conda deactivate