gpt4 book ai didi

python - pygame.error : video system not initialized when trying to run examples

转载 作者:行者123 更新时间:2023-12-04 18:33:50 25 4
gpt4 key购买 nike

我正在尝试学习如何使用 pygame,但我在运行它时遇到了问题。我按照这里的说明安装了它 https://www.pygame.org/wiki/GettingStarted .

他们告诉你安装它

python3 -m pip install -U pygame --user

然后用
python3 -m pygame.examples.aliens

我在 Ubuntu 中运行了这些命令并成功安装了 pygame。但是,当我尝试运行示例时,我得到
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4771:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default
Warning, no sound
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/Paul/.local/lib/python3.5/site-packages/pygame/examples/aliens.py", line 321, in <module>
if __name__ == '__main__': main()
File "/home/Paul/.local/lib/python3.5/site-packages/pygame/examples/aliens.py", line 188, in main
bestdepth = pygame.display.mode_ok(SCREENRECT.size, winstyle, 32)
pygame.error: video system not initialized

*我在微软商店的 Linux 的 Windows 子系统上使用 Ubuntu 终端。 https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6

**按照这些说明修复它。 https://virtualizationreview.com/articles/2017/02/08/graphical-programs-on-windows-subsystem-on-linux.aspx

最佳答案

要运行 linux 版本,您需要一个真正的 linux 系统,使用 X11 服务器来显示窗口——我认为这不适用于 windows 子系统。另一种选择是使用python for windows并直接在windows中安装pygame

关于python - pygame.error : video system not initialized when trying to run examples,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51161913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com