conda&&pip

本文详细介绍了如何使用conda管理和切换不同版本的虚拟环境,以及如何在conda和pip环境下更换镜像源,包括临时和永久切换,特别提到了代理环境下可能出现的问题。
摘要由CSDN通过智能技术生成
一、常用命令
查看conda版本: conda --version

查看所有虚拟环境: conda env list
激活某一虚拟环境: conda activate  <name>
创建一个新的虚拟环境: conda create -n <name> python=x.x
在当前环境中安装软件包: conda install <package name>
					pip install <package name>  
				// 注意pip和conda用的可能不是同一个镜像源
					
显示镜像源: conda config --show
删除镜像源: conda config --remove channels '<channels name>'  // 注意单引号
删除所有镜像源: conda config --remove-key channels
保存虚拟环境:conda activate your_env_name
			conda env export > environment.yml
加载虚拟环境:conda env create -f environment.yml
二、conda换源问题
更换清华源(其余相同):
	conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
    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 --set show_channel_urls yes  # 设置查询时显示通道
中科大源:
    https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
    https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
    https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
上海交大源:
    https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
    https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
    https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
三、pip换源问题
一、临时换源
	清华源: pip install <package name> -i https://pypi.tuna.tsinghua.edu.cn/simple
	阿里源: pip install <package name> -i https://mirrors.aliyun.com/pypi/simple/
	腾讯源: pip install <package name> -i https://mirrors.cloud.tencent.com/pypi/simple
	豆瓣源: pip install <package name> -i https://pypi.douban.com/simple/
  
二、永久换源
	清华源: pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
	阿里源: pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
	腾讯源: pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple
	豆瓣源: pip config set global.index-url https://pypi.douban.com/simple/
	换回默认源: pip config unset global.index-url
如果电脑开了代理,pip方式可能会出现如下错误

pip install 报错

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

啥都想学的大学生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值