[ubuntu]linux服务器每次重启anaconda环境变量失效

云服务器每次重启后conda不能用了,应该是系统自动把设置环境变量清除了。如果想继续使用,则可以运行一下

复制代码
minconda3激活方法:
source ~/miniconda3/bin/activate
anaconda3激活方法:
source ~/anaconda3/bin/activate

你也修改bashrc文件去修改环境变量,方法为

vi ~/.bashrc

在最后一行加入:

复制代码
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/用户名/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/用户名/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/home/用户名/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/用户名/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

上面是对miniconda3,下面是对anaconda3,注意上面用户名要替换自己真实系统用户名

复制代码
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/用户名/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/用户名/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/用户名/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/用户名/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

修改完毕后,别忘了让环境变量生效

source ~/.bashrc

相关推荐
未济4 天前
linux 配置环境变量
linux
傲世仙尊4 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
虎头金猫4 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
_艾伦 耶格尔.4 天前
进程间通信
linux
Liuqy-054 天前
Linux IO编程——静态库、动态库
linux
彧azz4 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
-梅4 天前
linux(8) 软硬链接
linux·运维·服务器
Wang's Blog4 天前
Java 项目实战: 外卖平台-文件下载与ServletOutputStream回写浏览器
服务器·项目开发
AIgorithmGEEK4 天前
[Linux]线程三部曲(上):一个执行流的诞生——从操作系统一路拆到 pthread_create
linux·线程·pid
琥珀色糖4 天前
SimlpeHttp
linux·服务器