我已经尝试了很多技巧,但在安装 pygame 时仍然收到此错误,我有 python 3.11 并尝试切换到 3.9 并得到相同的结果
安装命令:pip3 安装 pygame
收集游戏 使用缓存的 pygame-2.1.2.tar.gz (10.1 MB) 正在准备元数据 (setup.py) ...错误 错误:子进程退出并显示错误
× python setup.py egg_info未成功运行。 │ 退出代码:1 ╰─> [32行输出]
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using Darwin configuration...
/bin/sh: sdl2-config: command not found
/bin/sh: sdl2-config: command not found
/bin/sh: sdl2-config: command not found
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/j0/jkd60bqs5blcvy0t1_4r47sw0000gn/T/pip-install-ho52d8jb/pygame/setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/j0/jkd60bqs5blcvy0t1_4r47sw0000gn/T/pip-install-ho52d8jb/pygame/buildconfig/config.py", line 225, in main
deps = CFG.main(**kwds)
^^^^^^^^^^^^^^^^
File "/private/var/folders/j0/jkd60bqs5blcvy0t1_4r47sw0000gn/T/pip-install-ho52d8jb/pygame/buildconfig/config_darwin.py", line 132, in main
[DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl'])],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/j0/jkd60bqs5blcvy0t1_4r47sw0000gn/T/pip-install-ho52d8jb/pygame/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]
注意:此错误源自子进程,可能不是 pip 的问题。 错误:元数据生成失败
× 生成包元数据时遇到错误。 ╰─>
pygame(英语:pygame)注意:这是上面提到的软件包的问题,而不是pip。 提示:详见上文。
我通过将python版本切换到3.9并安装pip旧版本解决了它