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

在Windows 10通过CMD与pip安装pygame时遇错误求助

问题

Windows 10 Pro系统下,执行py -3.10 -m pip install pygame或pip install pygame均触发以下错误:

Microsoft Windows [Version 10.0.19044.2251]
(c) Microsoft Corporation. All rights reserved.

C:\Users\User>py -3.10 -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]
      WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
      Using WINDOWS configuration...
      # 完整错误核心:缺少Microsoft Visual C++ 14.0及以上版本的构建环境
      [end 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.
解决方法
  • 直接安装预编译包(推荐)
    执行命令跳过本地编译,直接使用官方预编译的二进制包:
    py -3.10 -m pip install pygame --only-binary :all:
    
  • 安装C++构建环境(若需本地编译)
    1. 下载微软Visual Studio构建工具,安装时勾选「C++构建工具」组件(包含MSVC编译器、Windows SDK等必要文件)。
    2. 安装完成后重启命令提示符,再重新执行py -3.10 -m pip install pygame。
  • 更新pip版本
    先升级pip到最新版,修复可能的兼容性问题:
    py -3.10 -m pip install --upgrade pip
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.11 00:25:22