【教程】centos安装anaconda并创建虚拟环境
下载
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh
其他版本:Old package lists — Anaconda documentation
国内源:清华源
错误: 无法验证 mirrors.tuna.tsinghua.edu.cn 的由 “/C=US/O=Let's Encrypt/CN=R3” 颁发的证书:颁发的证书已经过期。
此时按照提示,在下载指令后--no-check-certificate即可,如:
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh --no-check-certificate
安装
找到下载的可执行文件(默认为执行下载指令的目录)
bash Anaconda3-2021.11-Linux-x86_64.sh
随后enter,直到阅读完用户许可协议,之后输入yes同意
Do you accept the license terms? [yes|no]
[no] >>>
Please answer 'yes' or 'no':
>>> yes
紧接着会提示选择安装路径,默认为/用户(我这里是root)/anaconda3,按回车就是使用默认路径不修改,我这里默认
Anaconda3 will now be installed into this location:
/root/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/root/anaconda3] >>>
配置环境
配置环境前检查一下当前python环境,直接输入python,如果出现的不是anaconda的python版本,可以使用下面指令更改默认python环境,这里的/root/anaconda3为anaconda安装路径
export PATH=/root/anaconda3/bin:$PATH
source ~/.bashrc
之后编辑profile
vim /etc/profile
在末尾添加anaconda执行路径,可以使用vim快捷键shift+gg跳到末尾
PATH=$PATH:/root/anaconda3/bin
export PATH
保存后刷新环境变量
source /etc/profile
echo $PATH
测试
conda activate # 进入conda环境 出现(base)则说明安装成功
conda deactivate # 退出conda环境
创建虚拟环境
创建一个名为testenv的虚拟环境
conda create -n testenv python==3.7
激活环境
conda activate testenv
结束~

浙公网安备 33010602011771号