conda常用操作和配置镜像源

pip

临时使用国内镜像源

下载某一个包的时候,加上如下后缀就行

pip install xxx 
#中科大源、清华源、豆瓣源
-i https://pypi.mirrors.ustc.edu.cn/simple/
-i https://pypi.tuna.tsinghua.edu.cn/simple
-i https//pypi.doubanio.com/simple/ 

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uD8SZCjw-1664240931261)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220926103728097.png)]

永久使用国内镜像源

1、豆瓣源
pip config set global.index-url https//pypi.doubanio.com/simple/ 
2、清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
3、中科大源
pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple
4、配置成功会出现:

在这里插入图片描述

#保存路径
C:\Users\Administrator\AppData\Roaming\pip\pip.ini

打开保存路径的文件:

在这里插入图片描述

5、删除镜像源

直接将pip.ini文件删除即可

conda

0.出现 channels问题时候

Collecting package metadata (current_repodata.json): failed

UnavailableInvalidChannel: The channel is not accessible or is invalid.
  channel name: simple
  channel url: https://pypi.tuna.tsinghua.edu.cn/simple
  error code: 404

You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state,
and use `conda config --show-sources` to view config file locations.

步骤1:

conda clean -i

步骤2:

conda config --remove-key channels

1.查看默认源

conda config --show-sources

在这里插入图片描述

2.删除一个默认源

conda config --remove channels https://pypi.tuna.tsinghua.edu.cn/simple

在这里插入图片描述

3.增加一个默认源

# 清华源
 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/pkgs/free/

4.设置搜索时显示通道地址

conda config --set show_channel_urls yes

5.文件所在位置(进行增删)

也可以通过打开文件来增加删除镜像源

在这里插入图片描述
在这里插入图片描述

conda常用命令

1、创建虚拟环境

conda  create  --name  env_name python=3.7 

在这里插入图片描述

遇到报错:

UnavailableInvalidChannel: HTTP 404 NOT FOUND for channel simple

先删除镜像

conda config --remove-key channels

添加镜像

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 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

显示添加的镜像

conda config --show channels

2、激活虚拟环境

conda activate env_name

在这里插入图片描述

3、退出当前环境

conda deactivate

在这里插入图片描述

4、删除环境

conda remove  --name  env_name  --all

在这里插入图片描述

5、复制虚拟环境

conda  create  --name  new_env_name  --clone  old_env_name

在这里插入图片描述

6、查看当前所有环境

conda  info  -e

在这里插入图片描述

7、查看当前虚拟环境下的所有安装包

conda list  
conda list  -n  env_name

在这里插入图片描述
在这里插入图片描述

8、导出/创建虚拟环境

conda env export > environment.yml # 导出当前虚拟环境
pip freeze > requirements.txt #pip 导出
conda env create -f environment.yml # 创建保存的虚拟环境

在这里插入图片描述

9、批量导出虚拟环境中的所有组件

conda list -e > requirements.txt  # 导出
conda install --yes --file requirements.txt  # 安装

在这里插入图片描述

10、升级

conda  update  conda
conda  update  anaconda

11、卸载

rm  -rf  anaconda
  • 25
    点赞
  • 168
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

江小皮不皮

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

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

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

打赏作者

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

抵扣说明:

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

余额充值