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

iMac Monterey 12.6.3系统下pygame安装失败的问题求助

iMac Monterey 12.6.3系统下pygame安装失败的问题求助

各位开发者好,我在iMac Monterey 12.6.3系统上安装pygame时遇到了无法解决的问题,已经尝试过两种方法都失败了:

  • 按照一篇2015年的教程逐步操作
  • 分别在Python终端和Mac系统终端中使用pip命令安装

每次安装都会触发相同的错误,核心提示是pkg-config: command not found,最终导致元数据生成失败,完整错误信息如下:

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
╰─> [34 lines of output]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using Darwin configuration...
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "/private/var/folders/82/gx_9dw5926nd_8h271w_4fp00000gn/T/pip-install-r0d2u6u4/pygame_7a53717a6a7b41a5a1e4d3f23d0f3159/setup.py", line 359, in
buildconfig.config.main(AUTO_CONFIG)
File "/private/var/folders/82/gx_9dw5926nd_8h271w_4fp00000gn/T/pip-install-r0d2u6u4/pygame_7a53717a6a7b41a5a1e4d3f23d0f3159/buildconfig/config.py", line 225, in main
deps = CFG.main(**kwds)
^^^^^^^^^^^^^^^^
File "/private/var/folders/82/gx_9dw5926nd_8h271w_4fp00000gn/T/pip-install-r0d2u6u4/pygame_7a53717a6a7b41a5a1e4d3f23d0f3159/buildconfig/config_darwin.py", line 143, in main
find_freetype(),
^^^^^^^^^^^^^^^
File "/private/var/folders/82/gx_9dw5926nd_8h271w_4fp00000gn/T/pip-install-r0d2u6u4/pygame_7a53717a6a7b41a5a1e4d3f23d0f3159/buildconfig/config_darwin.py", line 110, in find_freetype
pkg_config = DependencyProg(
^^^^^^^^^^^^^^^
File "/private/var/folders/82/gx_9dw5926nd_8h271w_4fp00000gn/T/pip-install-r0d2u6u4/pygame_7a53717a6a7b41a5a1e4d3f23d0f3159/buildconfig/config_unix.py", line 39, in init
self.ver = config[0].strip()

IndexError: list index out of range
---
For help with compilation see:
https://www.pygame.org/wiki/MacCompile
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
[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.

我已经快束手无策了,有没有大佬能指点一下,到底需要做什么才能成功安装pygame?非常感谢大家的帮助!

备注:内容来源于stack exchange,提问作者Tiny

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.23 14:13:13