Python use overtime to solve the problem pip

  introduction

  There are bits before the group Friends of the questions in the group, said the use pip to install third-party packages encountered "Read timeout". I believe a lot of the time, we use pip will encounter this problem, so I think it is necessary to rewrite the article to summarize.

details as follows:

 

 

 

  solution

  Prior to this, you need to understand that the direct use pip install a timeout, because the vast majority of foreign pip source, so the domestic use, even if the network is stable, there is a certain timeout.

To solve the problem of overtime pip install packages, only two ways.

  The first: set the delay time

  This way is added directly after the pip command:

pip --default-timeout=1000 install requests

  "--Default-timeout = 1000" can be written in front or behind.

 

  The second: Replace pip download source

Some pip domestic image:

  Ali cloud  http://mirrors.aliyun.com/pypi/simple/ 
  China University of Science and Technology  https://pypi.mirrors.ustc.edu.cn/simple/ 
  watercress (douban)  http://pypi.douban.com/simple / 
  Tsinghua  https://pypi.tuna.tsinghua.edu.cn/simple/ 
  University of Science and technology of China  http://pypi.mirrors.ustc.edu.cn/simple/

Modify the source method:

  temporary use: 

It can be followed by the -i parameter specifies pip pip in the use of the source

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

  

  Permanent modifications:

windows Modified:

\ Computer user name \, create a named "pip" folder (eg: C: \ Users \ Administrator \ pip) directory \ user (or user): created in the folder a name in c "pip.ini" file, write the following in the file:

[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

linux Review: 
Create a folder named .pip user's home directory, creating good .pip folder, create a file named pip.conf, modification ~ / .pip / pip.conf (not create one) , reads as follows:

[Global] 
timeout = # 6000 set timeout, S 
index-specified URL = # http://pypi.douban.com/simple Download Source priority 
extra-index-url = http://pypi.douban.com/simple/ # second download source 
trusted-host = pypi.douban.com # may need to communicate https

 

  A key modification

The above method is modified pip source, of course, the one-click Review:

pip install pip -U # upgrade PIP 
PIP-config URL https://pypi.tuna.tsinghua.edu.cn/simple global.index SET # Tsinghua mirror the source as the default mirror source

  

  

 

Guess you like

Origin www.cnblogs.com/liudinglong/p/12634140.html
Recommended