1.添加环境变量
vim ~/.bashrc
2.按 i 进入编辑模式
在最后一行粘贴插入:
export PATH="/home/yqyang/anaconda3/bin:$PATH"
note:记得改为自己的路径
3.按esc退出编辑模型,输入:,接下来输入wq 保存退出
4.最后执行
source ~/.bashrc
我执行后source ~/.bashrc
出现了base环境,但是重新连接服务器后,每次都需要重新执行source ~/.bashrc
才能激活conda环境。
linux配置文件执行顺序为:
/etc/profile→ (~/.bash_profile | ~/.bash_login | ~/.profile)→ ~/.bashrc →/etc/bashrc → ~/.bash_logout
假如在~/.bash_profile文件中没有下面的代码:
if [ -f ~/.bashrc ] ; then
source .bashrc
fi
那么linux就不会自动执行~/.bashrc文件,所以你每次登陆的时候都要手动输入source ~/.bashrc。
所以需要vi ~/.bash_profile 添加代码块中的内容