CentOS7安装与卸载anaconda3基础步骤
# 1.简单步骤
# 1.1安装步骤
#下载
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2022.05-Linux-x86_64.sh
# \ --no-check-certificate
#执行安装命令
bash Anaconda3-2022.05-Linux-x86_64.sh
#按回车,直到让输入yes or no;输入
yes
#按回车,提示输入yes or no;输入
yes
#添加环境
source ~/.bashrc
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 1.2卸载步骤
#删除anaconda3
rm -rf /root/anaconda3
#删除环境变量
vi ~/.bashrc
#删除下面两行
export PATH="/root/anaconda3/bin:$PATH"
#重新加载环境
source ~/.bashrc
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 2.步骤详解
# 2.1下载
可以使用官网镜像,也可以使用国内镜像。
在 Anaconda | Anaconda Distribution (opens new window) 官方网站可以查看下载anaconda3,选择合适的版本。
在 Index of /anaconda/archive/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror (opens new window) 网站可以查看下载anaconda3,在这里选择合适的版本下载。
复制的具体地址如下。例如:
# 使用清华镜像地址
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2022.05-Linux-x86_64.sh
# 当然,也可以使用官网地址
wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
1
2
3
4
2
3
4
下载文件到指定目录。我这里放到home目录下
#切换到home目录
cd /home
#下载anaconda3安装文件,--no-check-certificate如果镜像网站证书有问题,忽略
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2022.05-Linux-x86_64.sh \
--no-check-certificate
1
2
3
4
5
2
3
4
5
如果提示未找到wget命令,安装wget即可
yum install wget
1
# 2.2安装
#执行安装命令
bash Anaconda3-2022.05-Linux-x86_64.sh
1
2
2
一直按回车,直到让输入yes or no
为止。默认安装位置 /root/anaconda3
。按回车确认,ctrl+c
退出,或者输入其他安装位置。
输入yes,以后每次进入服务器,都自动进入anaconda3的base环境。
如果不出意外,已经出现了congratulations!
查看环境
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/root/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/root/anaconda3/etc/profile.d/conda.sh" ]; then
. "/root/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/root/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
添加环境
source ~/.bashrc
1
安装完成!!!
# 3.其他
每次进入服务器,会自动进入base环境。此时使用的python是python3
#查看python版
python --version
#进入python
python
#退出python
exit()
1
2
3
4
5
6
2
3
4
5
6
退出或者进入base环境
#进入base环境
conda activate
#退出base环境
conda deactivate
1
2
3
4
2
3
4
取消每次进入服务器自动进入base环境
#取消自动进入base环境
conda config --set auto_activate_base false
#自动进入base环境
conda config --set auto_activate_base True
1
2
3
4
2
3
4
退出base环境后,此时使用的是系统自带的python2。
上次更新: 2025/03/11, 09:22:37