【发布时间】:2019-03-11 21:22:19
【问题描述】:
我正在尝试在 pygame 3.6 中创建一个看起来像聊天的窗口,我刚刚将我的 MacBook 更新到版本 10.13.6,在我这样做之前它运行良好,但在我收到消息后:非法指令:4。
代码
import pygame
from pygame.locals import *
import pygame.gfxdraw
pygame.init()
window_width=360
window_height=640
animation_increment=10
clock_tick_rate=20
size = (window_width, window_height)
screen = pygame.display.set_mode(size)
black = (0,0,0)
grey = (220,220,220)
shadow = (0, 255, 0, 100)
pygame.display.set_caption("BrAIn")
dead=False
clock = pygame.time.Clock()
background_image = pygame.image.load("background.png").convert()
micro = pygame.image.load("microphone.png")
PF = pygame.image.load("BrAIn.png")
while(dead==False):
for event in pygame.event.get():
if event.type == pygame.QUIT:
dead = True
font = pygame.font.Font("Impact copy.ttf", 52)
text = font.render('BrAIn', True, (0,0,0))
screen.blit(background_image, [0, 0])
pygame.gfxdraw.hline(screen, 0, 360, 40, shadow)
pygame.draw.line(screen, black, [0,62], [360,62], 2)
pygame.draw.line(screen, grey, [0,30], [360,30], 62)
pygame.draw.line(screen, grey, [0,620],[360,620],75)
pygame.draw.line(screen, black, [0,583], [360,583], 2)
screen.blit(micro, [152, 587])
screen.blit(PF, [-5, -7])
screen.blit(text, [125,0])
pygame.display.flip()
clock.tick(clock_tick_rate)
Python 3.6(和 2.7)在运行后也会崩溃。
【问题讨论】:
-
只是为了确认一下,您仅使用此 python 脚本而不是其他脚本收到此消息?使用旧版 MacOS 编译的二进制文件可能会导致此问题。见:stackoverflow.com/questions/14268887/…
-
是的,它只适用于 Python,我尝试了 C++、HTML(不知道为什么我尝试了在浏览器上运行的那种),我尝试了 C。除了 Python 2.7.13 之外,它们都可以工作和 Python 3.6.7。几乎每个模块都适用于 pygame。我尝试卸载并重新安装它,但发现这是 Macintosh 的问题,我没想到它会起作用。
-
我只是缩小了错误范围,如果我删除了
pygame.init()命令,(虽然它给了我其他相关的错误)它停止给我Illegal instruction: 4错误......不知道是什么这意味着虽然。是的,只有这个脚本(我没有其他真正使用 pygame 的脚本,所以......我无法真正检查它是否与 pygame 有关。提前致谢! -
我刚刚添加了一些文本,但它崩溃了......再次。
标签: python macos-sierra illegal-instruction