Anaconda中如何配置国内镜像源安装外部库(含conda永久配置和pip临时配置方法)

Anaconda中如何配置国内镜像源安装外部库


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

1.配置清华镜像源

直接在anaconda prompt下输入以下代码即可。
代码如下:

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 --set show_channel_urls yes

2.配置中科大镜像源

代码如下:

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
 #设置搜索时显示通道地址
conda config --set show_channel_urls yes

3、配置上海交通大学镜像源

命令如下:

conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
 
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes

4、显示添加的镜像源

conda config --show 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.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org/
豆瓣:https://pypi.douban.com/simple/

三、删除镜像源,换回默认源

conda config --remove-key channels

谢谢!!!!

  • 47
    点赞
  • 159
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
配置 Anacondapip镜像源,可以按照以下步骤进行操作: 配置 Anaconda 镜像源: 1. 打开 Anaconda Prompt(或者在命令行运行 Anaconda 相关命令)。 2. 输入以下命令,添加清华大学的 Anaconda 镜像源: ``` 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 ``` 或者,你可以添加其他镜像源,例如中科大镜像源: ``` conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes ``` 3. 配置完成后,可以使用 `conda install` 命令安装包时,Anaconda 将从镜像源下载。 配置 pip 镜像源: 1. 打开命令提示符或终端。 2. 创建或编辑 pip配置文件 `pip.ini`(Windows)或 `pip.conf`(Linux/macOS)。 - 对于 Windows 用户,在用户目录下创建一个名为 `pip.ini` 的文件(如果已存在则编辑它)。 - 对于 Linux/macOS 用户,在用户目录下创建一个名为 `pip.conf` 的文件(如果已存在则编辑它)。 3. 在配置文件添加以下内容,以使用清华大学的 pip 镜像源: ``` [global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple/ ``` 或者,你可以使用其他镜像源,例如中科大镜像源: ``` [global] index-url = https://mirrors.ustc.edu.cn/pypi/web/simple ``` 4. 保存配置文件。 配置完成后,你可以使用 `pip install` 命令安装包时,pip 将从镜像源下载。请注意,镜像源可能会有延迟或不同步的情况,如果遇到问题,可以尝试切换到其他镜像源或等待一段时间再试。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值