在 Ubuntu 上,尝试在我的 venv 中使用 pip 安装 pygame。
这是我尝试时抛出的完整错误消息:
$ pip install pygame
Collecting pygame
Using cached pygame-2.6.0.tar.gz (15.8 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [53 lines of output]
Skipping Cython compilation
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: freetype-config: not found
/bin/sh: 1: freetype-config: not found
/bin/sh: 1: freetype-config: not found
Hunting dependencies...
WARNING: "sdl2-config" failed!
WARNING: "pkg-config freetype2" failed!
WARNING: "freetype-config" failed!
---
For help with compilation see:
https://www.pygame.org/wiki/Compilation
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
Traceback (most recent call last):
File "/home/salvadorduran/Documents/Projects/musicplayer/mpEnv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/home/salvadorduran/Documents/Projects/musicplayer/mpEnv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/salvadorduran/Documents/Projects/musicplayer/mpEnv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-1fn_8yi6/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-1fn_8yi6/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-1fn_8yi6/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 497, in run_setup
super().run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-1fn_8yi6/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
exec(code, locals())
File "<string>", line 426, in <module>
File "/tmp/pip-install-o7k2dau0/pygame_136947bea63141b1b724389631340fca/buildconfig/config.py", line 234, in main
deps = CFG.main(**kwds, auto_config=auto)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-install-o7k2dau0/pygame_136947bea63141b1b724389631340fca/buildconfig/config_unix.py", line 245, in main
raise RuntimeError('Unable to run "sdl-config". Please make sure a development version of SDL is installed.')
RuntimeError: Unable to run "sdl-config". Please make sure a development version of SDL is installed.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Python 版本为 3.12.3,Ubuntu 版本为 24.04。一直在尝试寻找修复方法,但找不到。这里有什么想法吗?这是最近出现的问题,因为我昨天就这样做了,没有任何问题。
尝试使用以下命令