准备:配置 conda 镜像
1、安装conda镜像
# 添加 Anaconda 的 TUNA 镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
首先通过代码生成配置文件 .condarc
conda config --set show_channel_urls yes
配置文件的目录是:~/.condarc, 使用vim打开它,并添加我们需要的源:
vim ~/.condarc
添加清华的源码
channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
ssl_verify: true
2、命令行
列出当前所有的环境
conda info -e
创建一个虚拟环境
conda create -n name python=3.6 pandas=0.21
创建了一个名为name的新环境,同时安装了python 与 panda
激活环境
#win系统
activate name
#linux系统
source activate name
删除虚拟环境
conda remove -n name --all
conda clean -p #删除缓存
conda clean -y --all #删除pkgs目录下所有无用的安装包及cache
复制一个环境
conda create -n new_name --clone old name