天天看点

python pip 安装包下载过慢的解决方法

【转载】python pip 安装包下载过慢的解决方法 socket.timeout: The read operation timed out

1、使用pip安装第三方库过慢导致超时无法安装:

pip install reportlab
           

出现异常:

socket.timeout: The read operation timed out

2、 原因:

pip下载的时国外的资源,速度过慢,应该切换至国内镜像

3、解决方法:

更换 pip 源自国内镜像,在 pip install 后面添加 -i https://pypi.tuna.tsinghua.edu.cn/simple

上面是镜像地址,网上可以查到,这里提供两个速度快的:

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

清华:https://pypi.tuna.tsinghua.edu.cn/simple

4、使用示例:

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