conda常用命令

换源

# 默认源
https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch

# 查看源
conda config --get channels

# 删除源
conda config --remove channels https://repo.continuum.io/pkgs/free

# 清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
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/msys2/
conda config --set show_channel_urls yes

# 中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes

环境管理

#创建
conda create -n your_env_name python=3.8

# 激活
activate your_env_name | Linux: source activate your_env_name

# 退出
deactivate 

# 列出
conda env list | Linux: source deactivate

# 删除
conda remove -n your_env_name --all

包管理

# 查看版本
conda -V
python -V
nvcc -V

# 安装
conda install torchvision
pip install torchvision 

# 本地安装
conda install package_location

# 指定虚拟环境
conda install -n your_env_name package
    
# 指定channel
conda install torchvision -c pytorch

# with updata
pip install torchvision -U
pip install torchvision --update

# 安装到用户目录,出现读写权限问题时
pip install torchvision --user

# 列出包
conda list
pip list

# 删除虚拟环境包
conda remove --name your_env_name  package

# 帮助
conda install --help
pip install --help

# conda批量导出包含环境中所有组件的requirements.txt文件
conda list -e > requirements.txt

# conda批量安装requirements.txt文件中包含的组件依赖
conda install --yes --file requirements.txt
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容