pip install超时

报错信息

in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

我们在使用pip安装一些类库的时候发现会超时,导致无法正常下载,可能原因是因为网络的原因。

 

解决方法

1.增加超时的时间,如:

安装xlrd的时候指定超时时间为1000秒

pip install --default-timeout=1000 xlrd

 

2. 使用国内的pip源

比如用清华的源安装pandas

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

【更多源】

阿里云 https://mirrors.aliyun.com/pypi/simple/
中国科技大学https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban)http://pypi.douban.com/simple/
清华大学https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学http://pypi.mirrors.ustc.edu.cn/simple/

 

【配置默认镜像源】

如:我们想要把阿里云的镜像源,配成成我们的默认镜像源,这样,我们就不需要每次安装的时候都去用 -i 指定镜像源,在cmd窗口中执行如下2条命令

pip config --global set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config --global set install.trusted-host https://mirrors.aliyun.com

posted @ 2020-12-23 11:25  致命风华  阅读(1316)  评论(0编辑  收藏  举报