- 创建指定库版本的环境。
比如,创建环境torch,并且指定pytho版本为3.8。
conda create -n torch python==3.8
- 克隆一个已有的环境。
比如,克隆torch环境,并将新环境命名为torchClone。
conda create -n torchClone --clone torch
- 删除指定环境下的指定库。
比如,删除torh环境下的pandas库。
首先,从base环境切换到torch环境,然后按需求执行以下代码。
#方式1:会删除pandas以及关联它的库
conda uninstall pandas
#方式2:仅删除pandas这一个库【推荐使用】
conda uninstall pandas --force
4 指定镜像的情况下安装指定库。
比如给定源http://pypi.douban.com/simple,下载pandas库
conda install pandas -i http://pypi.douban.com/simple
- 删除指定环境。
比如删除torch环境。【注意:执行以下代码时要先deactivate torch环境】
conda remove -n torch --all #删除
- 查看已添加的镜像源。
conda config --show-sources
- 添加指定源。
比如添加源https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/。
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- 删除指定源。
比如删除源https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/。
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- 查看保存镜像源的文件位置,直接手动添加、删除以及移动镜像源。
conda config --show-sources
- 删除指定虚拟环境以及其包含的所有库。
conda remove --name 环境名称 --all -y
- 常用镜像源总结。
https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/