问题描述:
初次运行程序(来自《Python Cash Course》)
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")
# Set the background color.
bg_color = (230, 230, 230)
# 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()
出现空白页面,没有颜色〜〜〜
发现很多人遇到内样的问题:
Pygame not compatible with MacOS Mojave #555
从上面这个贴子中,有建议是下载Miniconda,但是我觉得有点麻烦😂〜〜
后来发现有个回复是:从官网下载最新Python包
- 从官网下载安装包:Python.org
我下载的是macOS 64-bit installer - 下载完成后,安装。安装成功后试试 python3 --version
$ python3 --version
Python 3.7.2
- 这时,重新运行程序,发现提示Pygame不存在了。再安装一次
$ pip3 install pygame
重新运行程序,成功了!
Screen Shot 2019-03-10 at 4.51.43 PM.png Screen Shot 2019-03-10 at 4.53.33 PM.png
网友评论