一、Conda源设置
1.修改为清华源
- 直接打开cmd输入以下命令
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud//pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
注意:PyTorch 官网给的安装命令需要去掉最后的
-c pytorch
,这样才能享受清华源的高速。
2.移除清华源
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
二、虚拟环境
1. conda常用的命令
- conda list 查看安装了哪些包。
- conda env list 或 conda info -e 查看当前存在哪些虚拟环境
- conda update conda 检查更新当前conda
- conda remove -n your_env_name(虚拟环境名称) --all 删除虚拟环境
2. 创建虚拟环境:
conda create -n your_env_name python=X.X(2.7、3.6.9等)
或者可以指定requirements.txt
文件创建环境:
conda create --name <env> --file <requirements.txt>
3. 激活环境:
conda activate your_env_name(虚拟环境名称)
4. 通过requirement.txt
安装包
(如果创建环境时没有指定requirements.txtt
)
conda install --yes --file requirements.txt
(找不到包可能会有问题,那就用pip)
pip install -r requirements.txt
网友评论