You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用CMD执行python -m pip install pygame安装Pygame失败求助

解决Windows下Pygame安装失败的问题

报错信息

C:\Windows\System32>python -m pip install pygame
Collecting pygame
  Using cached pygame-2.1.2.tar.gz (10.1 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [77 lines of output]
....

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

尝试使用命令 pip3 install pygame --use-deprecated=backtrack-on-build-failures 安装仍报错,作为Python新手无法解决,寻求帮助。

解决方案

  • 升级pip到最新版本,避免版本兼容问题:
    python -m pip install --upgrade pip
    
  • 直接安装预编译的wheel包(推荐新手使用,跳过源码编译步骤):
    pip install pygame --only-binary :all:
    
  • 检查Python版本兼容性:Pygame 2.1.2支持Python 3.7至3.10版本,若你的Python版本不在此范围,建议切换到兼容版本后再尝试安装。
  • 若必须从源码编译(不推荐新手),需安装Visual Studio Build Tools,并勾选“C++开发工具”组件,完成后重新执行安装命令。

内容的提问来源于stack exchange,提问作者mori

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 01:25:28