解决安装Python包时超时失败ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443)
问题:
今天在遇到了安装Python中的statsmodels包的时候一直超时失败报错如下
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
之前的安装的方式是:
pip install statsmodels
解决办法:
使用国内的镜像源安装。在原来安装时在命令里加一个参数 -i,然后在i后面加国内镜像地址。
选择国内的镜像源列表如下:
清华源: https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云: http://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/
选用的是清华源
修改为
pip install statsmodels -i https://pypi.tuna.tsinghua.edu.cn/simple/
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
重新安装成功了,这是临时使用
还可以永久设置,用全局配置(适用于所有用户)
在命令行中运行:
pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
或
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
如果要恢复原来配置,执行如下
pip config set global.index-url https://pypi.org/simple
或
pip config unset global.index-url
————————————————
版权声明:本文为CSDN博主「zhangvalue」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhangvalue/article/details/104271094
浙公网安备 33010602011771号