windows下设置pip国内源

使用pip安装python扩展时,如若没有配置国内镜像源,在未使用科学上网的情况下,其下载速度将会特别缓慢。因此,有些时候我们必须使用国内镜像源,来解决pip下载安装速度慢的问题,比较常用的国内镜像包括:

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

基于这些国内镜像源,在windows系统下,如果pip版本小于10.0.0,我们可通过在用户目录(Win XP:C:\Documents and Settings\Administrator\pip;Win7及其以上系统:C:\Users\Username\pip)下新建pip.ini,并在文件中指定扩展源即可,具体示例(以清华大学为例)如下:

[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple 
[install]  
trusted-host=pypi.tuna.tsinghua.edu.cn
disable-pip-version-check = true  
timeout = 6000

如果pip版本>=10.0.0,则可使用以下pip config set global.index-url命令进行配置,具体示例(以清华大学国内镜像源为例)如下:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

PS:如果仅是临时使用国内源,则可使用pip install -i命令指定当前安装所使用的镜像源即可,具体示例(以安装numpy为例)如下:

 

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy

 

  • 9
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
Windows系统中,你可以通过编辑pip的配置文件来配置国内镜像。这个配置文件位于用户根目录下,可以使用文本编辑器打开进行编辑。一个常用的配置文件是使用阿里云镜像的配置,其中镜像的地址为http://mirrors.aliyun.com/pypi/simple。你可以将这个地址替换到配置文件中的相应位置。这样,当你使用pip安装包时,它将使用阿里云镜像来加速下载速度。 另外,还有其他几个常用的国内镜像,如清华大学、豆瓣等。你可以选择其中一个镜像,并将其地址替换到配置文件中。这样可以根据你的个人喜好来选择使用哪个镜像。 需要注意的是,如果你只是临时使用某个镜像来下载软件包,你可以在使用pip的时候通过添加参数"-i"来指定镜像的地址。比如使用阿里云镜像下载Pillow包的命令是"pip install -i http://mirrors.aliyun.com/pypi/simple Pillow"。这样可以临时改变镜像,而不需要修改配置文件。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [pip配置国内镜像——最新详尽版](https://blog.csdn.net/chen565884393/article/details/128038281)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [pip配置国内镜像的配置文件](https://download.csdn.net/download/qq_35789981/12609009)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值