codecamp

python 解决pip下载缓慢的方法

很多人抱怨pip安装库有些时候太慢了,那是pip源的问题。

前面说过pip从PyPi中下载库文件,但由于PyPi服务器在国外,访问起来很慢。

但国内提供了很多镜像源,用来替代PyPi,像清华源、豆瓣源、阿里云源等。

这些镜像源备份了PyPi里的数据,由于服务器在国内,速度会快很多。

但镜像源数据有滞后性,比如说清华源的pypi 镜像每 5 分钟同步一次。

使用镜像源有两种方式,以清华源为例:

(1) 临时使用

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package matplotlib

除了matplotlib是要安装的库名外,其他都是固定格式

(2) 设为默认

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

设为默认后,以后安装库都是从清华源下载,而且无需再加镜像源网址

附主流镜像源地址

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


Python3 random 模块
python 怎么使用pip进行包管理
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

相关教程

Python基础教程

python内置库

python3 math模块

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }