
上QQ阅读APP看书,第一时间看更新
2.1 安装Pygame

2.1 安装Pygame
Pygame是一款专业的开发Python游戏程序的模块框架,这个框架是完全免费的。Pygame官方网站的下载地址是http://www.pygame.org/download.shtml,如图2-1所示。

图2-1 Pygame官方网站的下载地址
由图2-1可知,在Windows系统下,Pygame的最新版本只能支持Python 3.2。因为本书是基于Python 3.7编写的,所以官方的安装包不能满足我们的需求。幸运的是,读者可以登录国外大学网站来下载编译好的Python扩展库,在上面有适用于Python 3.7的Pygame。具体下载地址是https://www.lfd.uci.edu/~gohlke/pythonlibs/,如图2-2所示。

图2-2 适用于Python 3.6的Pygame
因为笔者使用的是64位Windows系统,所以单击“pygame-1.9.4-cp37-cp37m-win_amd64.whl”链接下载。下载完成后得到一个名为“pygame-1.9.4-cp37-cp37m-win_amd64.whl”的文件。进行本地安装时需要打开一个CMD命令窗口,然后定位切换到该下载文件所在的文件夹,并使用如下pip命令来运行安装。

注意:如果读者使用的是Python的低版本,并且Pygame官网提供了某个Python版本的下载文件,就可以直接使用如下pip命令或easy_install命令进行安装。
