Python包安装故障求助:安装cowsay时遭遇连接重置错误
解决pip安装cowsay时的ConnectionResetError(10054)问题
你遇到的是pip连接PyPI官方源时被远程主机强制关闭连接的错误,错误日志如下:
Obtaining dependency information for cowsay from https://files.pythonhosted.org/packages/f1/13/63c0a02c44024ee16f664e0b36eefeb22d54e93531630bd99e237986f534/cowsay-6.1-py3-none-any.whl.metadata WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /packages/f1/13/63c0a02c44024ee16f664e0b36eefeb22d54e93531630bd99e237986f534/cowsay-6.1-py3-none-any.whl.metadata WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /packages/f1/13/63c0a02c44024ee16f664e0b36eefeb22d54e93531630bd99e237986f534/cowsay-6.1-py3-none-any.whl.metadata WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /packages/f1/13/63c0a02c44024ee16f664e0b36eefeb22d54e93531630bd99e237986f534/cowsay-6.1-py3-none-any.whl.metadata WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /packages/f1/13/63c0a02c44024ee16f664e0b36eefeb22d54e93531630bd99e237986f534/cowsay-6.1-py3-none-any.whl.metadata WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /packages/f1/13/63c0a02c44024ee16f664e0b36eefeb22d54e93531630bd99e237986f534/cowsay-6.1-py3-none-any.whl.metadata ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/f1/13/63c0a02c44024ee16f664e0b36eefeb22d54e93531630bd99e237986f534/cowsay-6.1-py3-none-any.whl.metadata (Caused by ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)))
以下是可行的解决方法:
切换国内PyPI镜像源:国内访问官方源稳定性差,使用国内镜像能快速解决问题,执行命令:
pip install cowsay -i https://pypi.tuna.tsinghua.edu.cn/simple也可以配置永久使用镜像源,避免每次输入:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple检查网络与安全软件:重启路由器恢复网络连接;暂时关闭防火墙、杀毒软件或代理工具,这些程序可能拦截了pip的网络请求。
手动下载包安装:直接下载对应版本的cowsay包到本地,再执行本地安装:
- 下载
cowsay-6.1-py3-none-any.whl文件 - 执行本地安装命令:
pip install /path/to/cowsay-6.1-py3-none-any.whl(将
/path/to/替换为实际文件路径)- 下载
更新pip版本:旧版pip可能存在网络兼容问题,先升级pip再尝试安装:
pip install --upgrade pip
内容的提问来源于stack exchange,提问作者maryam
相关产品推荐
相关产品推荐

