anaconda安装
下载
下载地址:https://mirrors.aliyun.com/anaconda/
![在这里插入图片描述](https://img-blog.csdnimg.cn/e1c9e863797c492eb15df2c080533d54.png#pic_center)
安装、配置
安装
-
准备
-
安装
进入Anaconda3-2020.07-Linux-x86_64.sh
所在目录,执行安装
bash Anaconda3-2020.11-Linux-x86_64.sh
Welcome to Anaconda3 2020.11
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>> ENTER
Do you accept the license terms? [yes|no]
[no] >>> yes
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] >>> /application/anaconda3
Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> yes
经过以上步骤,最终显示如下图所示表示安装成功
![在这里插入图片描述](https://img-blog.csdnimg.cn/524ce807d33346e09273bde79481ff44.png#pic_center)
配置
执行source ~/.bashrc
命令,可以使用conda
命令
-
添加 Anaconda Python 免费仓库
cat >~/.condarc <<EOF
channels:
- defaults
show_channel_urls: true
default_channels:
- http://mirrors.aliyun.com/anaconda/pkgs/main
- http://mirrors.aliyun.com/anaconda/pkgs/r
- http://mirrors.aliyun.com/anaconda/pkgs/msys2
custom_channels:
conda-forge: http://mirrors.aliyun.com/anaconda/cloud
msys2: http://mirrors.aliyun.com/anaconda/cloud
bioconda: http://mirrors.aliyun.com/anaconda/cloud
menpo: http://mirrors.aliyun.com/anaconda/cloud
pytorch: http://mirrors.aliyun.com/anaconda/cloud
simpleitk: http://mirrors.aliyun.com/anaconda/cloud
EOF
-
设置搜索时显示通道地址
conda config --set show_channel_urls yes
conda clean -i
anaconda管理虚拟环境
-
创建python虚拟环境
source ~/.bashrc
conda create --name python37_env python=3.7
![在这里插入图片描述](https://img-blog.csdnimg.cn/9c97514e42db49c1939eb5b543d305ac.png#pic_center)
-
查看所有虚拟环境
conda env list
![在这里插入图片描述](https://img-blog.csdnimg.cn/48fcf49a6d3f43d6b5d9d4096a5f24b7.png#pic_center)
-
激活虚拟环境
conda activate python37_env
-
退出虚拟环境
conda deactivate
-
删除虚拟环境
conda remove --name python37_env --all
-
导出虚拟环境配置
conda env export >/root/python37_env.yml
-
从导出文件创建虚拟环境
conda env create -f /root/python37_env.yml
-
克隆虚拟环境
conda create --name clone_python37_env --clone python37_env
注意:
conda env export >/root/python37_env.yml
和 conda env create -f /root/python37_env.yml
命令可以实现在其他主机通过配置文件还原出原来的虚拟环境,但是仍然需要以下注意点:
- 其他主机必须以参考本主机anaconda的安装,最好安装方式一样(如果安装位置不一致,需要改一下导出文件中 prefix 的路径)
- anaconda安装好以后,相关源的配置与原主机的保持一样
- 配置默认的pip源应该与原主机保持一致
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)