python安装第三方库超时报错“Read time out”的解决办法

来源:互联网 发布:windows卸载程序在哪里 编辑:程序博客网 时间:2024/05/22 03:10

Question:
python安装第三方库超时报错—–Read time out

Answer:
①使用国内镜像安装
②设置超时时间

第一种方法:
pipy 国内镜像目前有:

   http://pypi.douban.com/ 豆瓣

   http://pypi.hustunique.com/ 华中理工大学

   http://pypi.sdutlinux.org/ 山东理工大学

   http://pypi.mirrors.ustc.edu.cn/ 中国科学技术大学

手动指定源:
在 pip 后面跟-i 来指定源,比如用豆瓣的源来安装 whois库:
pip install whois -i http://pypi.douban.com/simple
注意后面要有 /simple 目录!!!

配置文件 :
若需要创建或修改配置文件( linux 的文件在~/.pip/pip.conf , windows 在%HOMEPATH%\pip\pip.ini ),修改内容为:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
如果不加后面的 install
则需要每次在命令后面加上 –trusted-host

第二种方法:
安装whois库:
pip –default-timeout=100 install -U whois

4 0