如何获得 Python3 的 pygame?

The*_*o61 9 python 11.10

Universe 存储库中有一个适用于 Python2 的包 (python-pygame)。但是,我想完成Invent with Python book 中的教程。通过 SPM (Synaptic),我找不到 Python3 的 pygame 资源。

另外,我查看了Pygame网站,并不清楚 Pygame 是否可用于 Python3(尽管书中指出它是)。

有人可以帮助我解决我的困境吗?

Ser*_*gey 6

来自Pygame 维基

Pygame 是否适用于 Python 3?

是的。Pygame 1.9.2 支持 Python 3.2 及更高版本。只有孤立的 _movie 模块(默认情况下未构建)没有。

但是,Ubuntu 存储库中似乎没有针对 Python 3 的预打包 Pygame 包,至少从 14.04 开始。

我建议您从 pygame 网站获取源包并将其本地安装到 virtualenv 或 buildout 中。无论如何,以邪恶的方式全局安装python模块:)以下是说明:http : //www.pygame.org/wiki/CompileUbuntu

或者你可以试试这个 PPA:https : //launchpad.net/~thopiekar/+archive/ubuntu/pygame


The*_*o61 5


Thanks to Sergey's suggestion, this is how to get it working:
INSTALL
(1) Move to a directory where you want the source code to be downloaded to
(2) svn co svn://seul.org/svn/pygame/trunk pygame
    NOTE:  Be sure to use the svn method.  Simply downloading the pygame*.tar.gz
           file from the pygame downloads page didn't work!
(3) cd pygame
(4) python3 config.py
    NOTE:  This confirms that you have the dependencies.
(5) python3 setup.py build
(6) sudo python3 setup.py install
    NOTE:  On my machine, I have the distro's python3.2 installed (which is in
           the /usr/lib directory).  This step places the pygame module into
           /usr/local/lib -- which is what you want (per Sergey's suggestion).

TEST
(1) python3
(2) At the '>>>' prompt, type "import pygame"
    VALIDATION:  If you get another '>>>' prompt, all is well.
Run Code Online (Sandbox Code Playgroud)

根据 BlaXpirit,您也可以选择使用 hg 而不是 svn:

hg clone https://bitbucket.org/pygame/pygame