问题描述
我正在尝试安装 Pygame,但出现此消息:
WARNING: retrying (Retry(total=4,connect=None,read=None,redirect=None,status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org',port=443): Read timed out. (read timeout=15)")': /simple/pygame/
WARNING: retrying (Retry(total=3,port=443): Read timed out. (read timeout=15)")': /simple/pygame/
WARNING: retrying (Retry(total=2,port=443): Read timed out. (read timeout=15)")': /simple/pygame/
WARNING: retrying (Retry(total=1,port=443): Read timed out. (read timeout=15)")': /simple/pygame/
WARNING: retrying (Retry(total=0,port=443): Read timed out. (read timeout=15)")': /simple/pygame/
ERROR: Could not find a version that satisfies the requirement pygame (from versions: none)
ERROR: No matching distribution found for pygame
我使用的是 python 3.9.2
解决方法
您可能需要让 IPv4 优先于 IPv6。
如果你在 windows 上运行,请以管理员权限打开 CMD 并应用以下命令:
netsh interface ipv6 set prefixpolicy ::ffff:0:0/96 46 4
如果您在 Ubuntu 上运行(您可以轻松转换任何其他 Linux 发行版的命令):
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
,
您的消息是这样说的:
在连接中断后,由 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org',port=443): Read 超时 .(阅读超时=15)”)
您可能会使用命令提示符(使用 pip)安装 pygame
但是 pip 是一个从 Pypi.org 下载模块的模块。
因此,您的计算机可能无法下载库。
此问题是由互联网访问不良引起的。
如何解决这个问题:
1. Pip 似乎无法在 Python 3.9 上正常工作,因此您应该 1. upgrade pip 或 2. 将 Python 降级为工作版本。
2.我这不能解决您的问题,请尝试与您的连接相关的这些想法
- 检查您的互联网连接并重试
- 也许您使用了代理:override
- 可以通过在命令提示符中输入以下内容来覆盖
timed out
错误:pip --default-timeout=1000 install [PACKAGENAME]
- 它也可能是防火墙错误,但您可以再次覆盖它like that.
解决方案
错误信息中最重要的部分是:
ERROR: Could not find a version that satisfies the requirement pygame (from versions: none)
ERROR: No matching distribution found for pygame
您之所以得到这个,是因为 pip
找不到与 pygame
中的 python3.9
兼容的稳定版本的 PyPi
。错误消息的其余部分是超时发生这种情况是因为 pip
无限期地尝试查找匹配项,但总是为空。
这些是您的选择:
-
等待为
添加支持Python3.9
-
像这样安装不受支持的开发版本:
pip install pygame==2.0..0.dev22
或
python -3.9 -m pip install pygame
-
您可以将您的版本回滚到
ptyhon3.8
或更早版本。