首页 > 解决方案 > pygame.init() 导致崩溃

问题描述

这是我在测试可能导致崩溃的原因时所做的简单测试代码:

import pygame

pygame.init()

print("Hello World!")

问题是当我运行我的代码时,它从不打印Hello World!,它Hello from the pygame community. https://www.pygame.org/contribute.html从打印import pygame,稍等片刻,然后就像我的程序停止了一样。

从终端运行它给出

C:\Users\...\game>py game.py
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html

C:\Users\...\game>

在 IDLE 中一步一步做看起来像

>>> import pygame
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> pygame.init()

=============================== RESTART: Shell ===============================
>>> 

如果我从 Visual Studio 运行它,它会打开一个错误窗口,显示“调试适配器意外退出”。

我已经对该问题进行了广泛的研究,但只发现了两个未答复的帖子。如果可能有帮助,我使用 python 3.6.6 和 pygame 1.9.6(在 Windows 10 上)

标签: pythonpython-3.xpygame

解决方案


推荐阅读