【Pip】Pip安装配置不同平台镜像源

本文介绍了如何在遇到pip/pip3下载超时时,通过替换为国内镜像库(如豆瓣、阿里云、清华源、中国科技大学)进行安装,以及在`pip.conf`中设置trusted-host以永久解决下载问题。
摘要由CSDN通过智能技术生成

在使用pip / pip3 环境安装时,经常会出现下载超时,主要是因为访问国外网站,导致速度慢造成!所以我们可以采用以下命令格式,采用国内的镜像库进行下载安装(以安装 django 为例):

一、镜像库更换下载

格式:pip install [安装包名]==[指定版本号]  -i  镜像库网址 --trusted-host 镜像库主域名

采用豆瓣镜像库安装

pip install django==1.11.7 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

采用阿里云镜像库安装

pip install django==1.11.7 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

采用清华源镜像库安装

pip3 install django==1.11.7 -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

采用中国科技大学镜像库安装

pip3 install django==1.11.7 -i https://pypi.mirrors.ustc.edu.cn/simple/  --trusted-host pypi.mirrors.ustc.edu.cn

采用中国科学技术大学镜像库安装

pip3 install django==1.11.7 -i http://pypi.mirrors.ustc.edu.cn/simple/ --trusted-host pypi.mirrors.ustc.edu.cn

二、在pip.conf中配置,加入trusted-host选项,该方法是一劳永逸

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值