更改conda和pip的镜像配置文件

时间: 2023/11/04
系统: Windows

问题描述

需要在不同的镜像地址里下载所需要的包

解决

Python常用国内pip镜像源:

阿里云:https://mirrors.aliyun.com/pypi/simple/

百度: https://mirror.baidu.com/pypi/simple/

清华:https://pypi.tuna.tsinghua.edu.cn/simple/

中科大: https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣:http://pypi.douban.com/simple/

搜狐:http://mirrors.sohu.com/Python/

临时设置

pip install -i [https://mirrors.aliyun.com/pypi/simple/](https://link.zhihu.com/?target=https%3A//mirrors.aliyun.com/pypi/simple/) numpy #这条命令将使用阿里云 PyPI 镜像安装 numpy 包

永久设置—pip

  1. 找到pip的配置文件夹
    我的路径为C:\Users\RyanWang\AppData\Roaming\pip

    pip配置文件

    pip的配置文件

  2. 进行编辑,添加软件源

    [global]
    timeout = 60
    index-url = https://mirrors.aliyun.com/pypi/simple/
    [install]
    trusted-host=mirrors.aliyun.com
    
    • 代码解释
      1. [global]:表示下面的配置项适用于全局范围,即对所有的pip操作都生效。
      2. index-url:指定了pip在搜索和下载Python包时要使用的索引源的URL
      3. [install]:表示下面的配置项适用于安装操作
      4. trusted-host:这是一个配置项,用于指定pip信任的主机,pip在与该主机建立连接时不会发出警告。

永久设置—conda

  1. 找到conda配置文件,我的路径为C:\Users\RyanWang

    conda的镜像文件

  2. 编辑设置

    channels:
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
      - defaults
    show_channel_urls: True
    

    也可以添加下列镜像

    - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
    - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
    - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    

参考网站

python pip 下载默认源更改(Windows)_pip默认源_跳舞的Tango的博客-CSDN博客

conda安装和pip安装的国内镜像配置_conda 国内channel-CSDN博客

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

掌丶灯

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

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

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

打赏作者

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

抵扣说明:

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

余额充值