作者:手机用户2502911283 | 来源:互联网 | 2022-12-02 17:49
我最近买了一个新的macbook,我一直在努力pygame
工作,但还没有成功.我变得非常绝望,我真的可以使用一些帮助.
我已安装pygame 1.9.4
,即使我在运行pygame
代码时没有收到任何错误消息,它也不会显示任何内容,只有空白屏幕.我正在使用以下代码来测试它:
import pygame
pygame.init()
screen = pygame.display.set_mode((800,600))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
screen.fill((255,0,0))
pygame.display.update()
pygame.quit()
在我的旧Macbook上,测试代码给了我一个预期的红色屏幕.两个macbook都在运行python 2.7.10
.
有谁知道我做错了什么?我认为我安装的方式pygame
与我在旧Macbook上完全一样,唯一的区别似乎是操作系统.
编辑1:我在Sublime Text中编写脚本并在Terminal中运行程序.
截图
编辑2:我通过将操作系统降级为macOS High Sierra让pygame再次工作.
1> René Dudfiel..:
最新编辑更新工作::从MacOS 10.14.1,如果您从官方python页面下载Python 3.7.2的官方macOS x64安装程序包,然后pip3安装pygame它可以工作.
MacOS存在问题.应该可以在SDL中修复.
https://discourse.libsdl.org/t/macos-10-14-mojave-issues/25060/8
https://bugzilla.libsdl.org/show_bug.cgi?id=4274
pygame问题在这里:https://github.com/pygame/pygame/issues/555
自制问题在这里:https://github.com/Homebrew/homebrew-core/issues/33016
尝试使用Mojave(MacOS 10.14.3)和pygame 1.9.4的第三版,通过Python 3.7.3形成其[官方网站](https://www.python.org/downloads/)。 /我曾在macOS 10.14.1上尝试过3.7.2,但没有任何更好的结果。还有其他人能够使它正常工作吗?