【问题标题】:Python crashing on loading pygamePython在加载pygame时崩溃
【发布时间】:2017-10-20 04:15:57
【问题描述】:

我已经安装了 pygame 和 numpy 并且似乎都在 win10 上工作 来自 python 外壳:

import pygame

(工作)

输入脚本:

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 窗口打开,python 停止。在我退出 python 之前,在 python shell 中说“没有名为 pygame 的模块”

【问题讨论】:

  • 您是否检查过您的 shell 使用的 python 版本,与您的系统默认使用的 python 版本相比?

标签: python-3.x pygame


【解决方案1】:

尝试使用 pip 安装。从命令行输入:

pip install pygame

【讨论】:

  • 检查 pip 是否安装到 Python3 环境而不是 Python2。 pip3 会是更好的选择
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-07-03
  • 2013-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多