Conda常用命令

Conda常用命令

环境管理

查看所有环境

powershell
conda env list

创建环境

powershell
conda create -n <环境名> python=<版本号>

激活环境

powershell
conda activate <环境名>

退出环境

powershell
conda deactivate

移除环境

powershell
conda remove -n <环境名> --all

复制环境

powershell
conda create -n <新环境名> --clone <原环境名>

包管理

搜索包

powershell
# PyPI中,功能疑似被禁用,建议直接使用网页搜索
pip search <包名>

查看已经安装的包

powershell
# 列出已安装的包
pip list
# 查看指定包详细信息
pip show <包名>

安装包

powershell
# 安装最新版本
pip install <包名>
# 安装指定版本
pip install <包名>==<版本号>
# 安装指定范围的某个版本
pip install <包名>>=<版本号>,<<版本号>
# 从文件批量安装依赖
pip install -r requirements.txt

移除包

powershell
pip uninstall <包名>

更新包

powershell
pip install --upgrade <包名>
pip install -U <包名>

检查包依赖冲突

powershell
pip check

pipi镜像源

powershell
# 单次使用源
pip install <包名> -i https://pypi.tuna.tsinghua.edu.cn/simple
# 永久设置默认源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Conda镜像源

powershell
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --set show_channel_urls yes