【发布时间】:2018-01-03 11:49:23
【问题描述】:
代码是这样的
import sys
import pygame
def run_game():
# Initialize game and create a screen object.
pygame.init()
screen = pygame.display.set_mode((1200, 800))
pygame.display.set_caption("Alien Invasion")
# Start the main loop for the game.
while True:
# Watch for keyboard and mouse events.
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
# Make the most recently drawn screen visible.
pygame.display.flip()
run_game()
错误是这样的
第 2 行,导入 pygame ModuleNotFoundError:没有名为“pygame”的模块
【问题讨论】:
-
你需要安装pygame。
-
pygame不是标准模块 - 您必须先使用pip install pygame安装它。更多内容official documentation -
我已经安装好了。它已成功安装,但它只是没有导入
-
你用什么系统?你用什么命令安装的?您在安装过程中收到错误消息吗?你安装了两条蟒蛇吗?你使用 PyCharm 还是其他 IDE?
-
我使用 64 位 Windows 7。不,我在这个版本(32 位)中没有收到任何消息。但它确实在 amd_64 位文件中