我们下载python的库一般会使用pip工具。但在下载的过程中经常会timeout,这是因为资源在国外,我们国内某些资源下载速度特别慢,主要有两种方法解决。

 

一、设置pip timeout超时时间

创建或修改pip.conf配置文件:

$ sudo vi ~/.pip/pip.config //linux or MacOS
 
timeout = 6000    #设置pip超时时间

 

二、使用国内镜像

使用镜像来替代原来的官网,方法如下:(推荐这种方法)

1. pip install redis -i https://pypi.douban.com/simple

 -i:指定镜像地址

 

2. 创建或修改pip.conf配置文件指定镜像地址:

[global]
timeout = 6000
index-url = http://pypi.douban.com/simple/ 
[install]
use-mirrors = true
mirrors = http://pypi.douban.com/simple/ 
trusted-host = pypi.douban.com

 

相关文章:

  • 2021-05-22
  • 2021-04-20
  • 2021-08-23
  • 2021-10-07
  • 2021-06-13
  • 2021-10-28
  • 2021-12-27
  • 2021-09-21
猜你喜欢
  • 2022-01-18
  • 2021-10-06
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
  • 2021-06-23
  • 2021-06-20
相关资源
相似解决方案