conda添加镜像源与channels

作者 : admin 本文共1743个字,预计阅读时间需要5分钟 发布时间: 2024-06-16 共1人阅读

文章目录

  • 一、conda下添加国内镜像源(window下)
  • 二、pip配置国内镜像源(window下,临时修改)
  • 三、conda源的定义

一、conda下添加国内镜像源(window下)

1、为【channels】配置清华镜像通道
直接在anaconda prompt下输入以下代码即可。

为【channels】源添加通道

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/

custom_channels源添加
conda config --add custom_channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

#设置搜索时显示通道地址
conda config --set show_channel_urls yes

2、设置搜索时显示通道地址

conda config --set show_channel_urls yes

3、显示【channels】源添加的所有通道

conda config --show channels

conda添加镜像源与channels插图

显示所有源的channels:

conda config --show-sources

conda添加镜像源与channels插图(1)

4、删除【channels】源,换回默认源【default】

conda config --remove-key channels

二、pip配置国内镜像源(window下,临时修改)

1、配置pip镜像源
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple/

pip install numpy -i 镜像源网址
pip install numpy -i https://mirrors.aliyun.com/pypi/simple/

国内常用源镜像地址,可自行替换。

清华:https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云:https://mirrors.aliyun.com/pypi/simple/
中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣:https://pypi.douban.com/simple/

三、conda源的定义

custom_channelsdefault_channelschannels都是.condarc文件中用于配置软件包源的选项,但它们之间有一些不同。

custom_channels是一个字典,其中包含了自定义软件包源的名称和URL。当你运行conda install等命令时,如果指定了自定义软件包源的名称,conda会使用custom_channels中列出的对应URL进行搜索。需要注意的是,如果你在命令行中指定了软件包源,conda会优先使用指定的软件包源,而不是custom_channels中列出的软件包源。

default_channels是一个列表,其中包含了conda搜索软件包时需要使用的默认软件包源。当你运行conda install等命令时,如果没有指定软件包源,conda会使用default_channels中列出的软件包源进行搜索。和custom_channels不同的是,default_channels中列出的软件包源是conda内置的、预定义的软件包源。

channels也是一个列表,其中包含了conda搜索软件包时需要使用的软件包源。和default_channels不同的是,channels列出的软件包源会覆盖default_channels中列出的软件包源。当你运行conda install等命令时,如果指定了软件包源,conda会使用channels中列出的软件包源进行搜索。

本站无任何商业行为
个人在线分享 » conda添加镜像源与channels
E-->