【Conda常用命令——创建环境/配置国内镜像】

这篇博客记录了conda环境的创建、查看与管理,包括如何配置国内镜像以加速包的下载。此外,还介绍了如何使用conda和pip安装requirement文件,并提供了使用豆瓣和清华源加速pip安装的示例。
摘要由CSDN通过智能技术生成

Conda常用命令

自己平时在用unix环境时常常会忘记一些conda的命令,在这里做一些记录

创建环境

# 命令
conda create --name 环境名 python=python版本
conda create -n 环境名 python=python版本
# 示例
conda create --name myenv python=3.8

查看conda环境

# 命令
conda info -e
conda env list

查看conda当前环境已经安装的python库

# 命令
conda list

配置国内镜像

#设置清华镜像
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/conda-forge/
conda config --add channels conda-forge
#设置搜索时显示通道地址
conda config --set show_channel_urls yes

使用Conda安装requirement依赖文件

conda install --yes --file requirements.txt

或者使用pip安装

pip install -r requirements.txt

安装部分软件包时可以使用国内镜像加速

# 使用豆瓣源(相对更快,但是可能会出现包无效的情况)
pip install numpy -i http://pypi.douban.com/simple/ --trusted-host = http://pypi.douban.com
pip install -r requirements.txt -i http://pypi.douban.com/simple/ --trusted-host = http://pypi.douban.com
# 使用清华源(稳定)
pip install numpy -i http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host = http://pypi.tuna.tsinghua.edu.cn
pip install -r requirements.txt -i http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host = http://pypi.tuna.tsinghua.edu.cn
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值