细分错误:我运行Pygame时出现11个错误 [英] Segmentation fault: 11 when I run Pygame

查看:126
本文介绍了细分错误:我运行Pygame时出现11个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人在此处提出了类似的问题,但没有得到回答.

Somebody asked a similar question here, but it didn't get answered.

我有Python 2.7.11,OSX 10.11和pygame 1.9.1.每次我运行该程序时,都会出现该窗口,然后关闭并显示错误分段错误:11".我从pygame教程中获得了此信息,然后对其进行了少许修改以防止无限循环. (即使我使用了本教程中使用的"while 1"循环,也会发生相同的错误.)

I have Python 2.7.11, OSX 10.11, and pygame 1.9.1. Every time I run the program, the window appears, and then closes with the error "Segmentation fault: 11". I got this from the pygame tutorials, and then modified it slightly to prevent an infinite loop. (the same error occurs even if I use the "while 1" loop used in the tutorial.)

为什么会发生这种情况,我该如何解决?谢谢!

Why is this happening and how can I fix it? Thanks!

import sys, pygame
pygame.init()

size = width,height = 320,240
speed = [2,2]
black = 0,0,0

screen = pygame.display.set_mode(size)

ball = pygame.image.load("ball.gif")
ballrect = ball.get_rect()

for i in range(100):
    ballrect = ballrect.move(speed)
    if ballrect.left < 1 or ballrect.right > width - 1:
        speed[0] = -speed[0]
    if ballrect.top < 1 or ballrect.bottom > height - 1:
        speed[1] = -speed[1]

    screen.fill(black)
    screen.blit(ball,ballrect)
    pygame.display.flip()

推荐答案

以防万一其他人遇到相同的问题,我也弄清楚了.之所以崩溃,是因为OS X 10.11随附的SDL1有点损坏.

Just in case anyone else has the same problem, I figured it out. It crashes because the SDL1 that comes with OS X 10.11 is a bit broken.

解决方案是从此处下载运行时库SDL1.下载后打开dmg,然后将SDL.framework文件从其中移动到/Library/Frameworks中.因为那里已经有一个,所以我合并了两个,但是替换也应该起作用. Pygame现在可以工作了!

The solution is to download the runtime library SDL1 from here. Open the dmg after downloading it, and move the SDL.framework file from it into /Library/Frameworks. Since there was already one there, I merged the two, but replace should also work. Pygame works now!

这篇关于细分错误:我运行Pygame时出现11个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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