Anaconda-配置环境常用命令

创建一个环境

conda create --name test python==3.8

 

查看所有环境

conda info -e

 

激活和退出环境

conda activate test
conda deactivate

 

删除环境

conda env remove --name test

 

更改 python 的版本

conda install python==3.9 -n test

 

查看 config

conda config --show

 或者 pip config

pip config list

 

添加 channels 

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

 或者

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

 从 channels 中安装包时显示 channel 的 url 

conda config --set show_channel_urls yes

环境依赖设为灵活

conda config --set channel_priority flexible

 

移除 channels

conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

或者移除现有源

conda config --remove-key channels

 

查看环境中的包

conda list -n test
pip list

 

搜索包的信息

conda search scipy

 

安装包

conda install scipy==1.7.1
pip install scipy==1.7.1

或者用 -n 指定环境, -c 指定通过某个 channel 安装

conda install -n test scipy

 

更新包

conda update -n test scipy

 

卸载包

conda uninstall scipy

 或者

pip uninstall torch

 

更新 conda

conda update conda

 

批量安装包

在一个txt文件内填写需要的库的名字(==package_version)

C:
cd C:\Users\123\Desktop
conda install --file=test.txt

或者

pip install -r C:\Users\123\Desktop\test.txt

 

显示GPU的所有信息

nvidia-smi

 

检查 cuda 是否可用

python
import torch
torch.cuda.is_available()

 

退出python

exit()

或者

quit()

 

posted @ 2022-06-09 22:21  Khru  阅读(97)  评论(0)    收藏  举报