Ubuntu中Anaconda安装与使用

2020-04-13  本文已影响0人  zhaoxin94

一、Conda源设置

1.修改为清华源

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常用的命令

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

上一篇下一篇

猜你喜欢

热点阅读