Python Launcher 没有响应 Pygame [英] Python Launcher not responding with Pygame

查看:60
本文介绍了Python Launcher 没有响应 Pygame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Python 和 Pygame 的新手,现在我正在尝试用一些简单的代码打开一个测试窗口:

I am new to Python and Pygame, and right now I'm trying to open a test window with some simple code :

import pygame, sys

from pygame.locals import *
pygame.init()

DISPLAYSURF = pygame.display.set_mode((400, 300))

pygame.display.set_caption('Hello World!')

while True: # main game loop

    for event in pygame.event.get():

        if event.type == QUIT:
            pygame.quit()

            sys.exit()
    pygame.display.update()

当我尝试运行它时,我在终端收到欢迎消息(pygame 1.9.6来自 pygame 社区的您好.https://www.pygame.org/contribute.html") 和 python 启动器启动,但它永远不会打开.图标只是在 Dock 中弹跳了一会儿,然后说应用程序无响应.

When I try to run it, I get the welcome message in terminal ("pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html"), and the python launcher starts, but it never opens. The icon simply bounces in the dock for a while, and then says Application Not Responding.

Python Launcher用其他没有使用pygame的代码正常初始化,python、pip和pygame都是最新的.我还尝试运行教程中的其他代码段,但一切都得到了相同的结果.我今天安装了新的 macOS Catalina,如果这有什么不同的话.

Python Launcher initialized normally with other code that doesn't use pygame, and python, pip and pygame are all up to date. I have also tried to run other pieces of code from tutorials, but everything gets the same result. I installed the new macOS Catalina today, if that makes a difference.

感谢您的帮助!

推荐答案

我遇到了完全相同的问题,上面的代码基本相同,升级 pygame 库解决了这个问题,正如 Tom-cz 在一个类似的问题中所回答的 https://stackoverflow.com/a/60496097/13407487.

I had the exact same problem with essentially the same code above, and upgrading the pygame library solved the issue, as answered by Tom-cz in a similar issue https://stackoverflow.com/a/60496097/13407487.

如果您在 IDLE 或 python 控制台中运行上述代码,您会看到它导致 Python Launcher 挂起(并在 Dock 中弹跳)并且没有出现窗口:

If you run the above code in IDLE or python console, you'll see it cause the Python Launcher to hang (and bounce in the dock) with no window appearing:

DISPLAYSURF = pygame.display.set_mode((400, 300))

解决方案是升级pygame:

The solution was to upgrade pygame:

python3 -m pip install pygame==2.0.0.dev6

我的设置:MacOS Catalina 10.15.4蟒蛇 3.8.1pygame 1.9.6 -> 我升级到 2.0.0.dev6

My setup: MacOS Catalina 10.15.4 Python 3.8.1 pygame 1.9.6 -> which I upgraded to 2.0.0.dev6

这篇关于Python Launcher 没有响应 Pygame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆