1、安装pygame的某些依赖包需要homebrew,安装命令如下
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2、安装运行游戏需要的基础库
brew install hg sdl sdl_image sdl_ttf
3、安装游戏中包含声音的库
brew install sdl_mixer portmidi
4、安装pygame
pip3 install pygame
5、检查是否安装成功,打开python终端,在命令行输入import pygame,输出以下内容表示安装成功
>>> import pygame
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html