python中安装下载超时,下载不了安装包

python3 -m pip install scapy

执行上面命令报错,下载超时,下载不了安装包

Collecting scapy
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)")': /packages/52/e7/464079606a9cf97ad04936c52a5324d14dae36215f9319bf3faa46a7907d/scapy-2.4.3.tar.gz
  WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000227D115DD48>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/52/e7/464079606a9cf97ad04936c52a5324d14dae36215f9319bf3faa46a7907d/scapy-2.4.3.tar.gz
ERROR: Operation cancelled by user

解决办法:

pip install <包> -i <源> --trusted-host <源域名>

<包>为你要下载的安装包

例如:

 pip install scapy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

附:

一些pip源

阿里云 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/
文章仅作为学习笔记,欢迎指正,不喜勿喷!
原文地址:https://www.cnblogs.com/Hunter-01001100/p/11799810.html