我怎样才能获得Python3的pygame?

可以从Universe存储库中获得Python2的包(python-pygame)。 但是,我想学习Invent with Python一书中的教程。 通过SPM(Synaptic),我找不到Python3的pygame资源。

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

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

来自Pygame wiki :

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


 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. 

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

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

有人需要制作一个python3-pygame包来做到这一点,但还没有人

 sudo apt-get install mercurial python3-dev python3-numpy libav-tools \ libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev \ libsdl1.2-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev hg clone https://bitbucket.org/pygame/pygame cd pygame python3 setup.py build sudo python3 setup.py install 

再次感谢大家。

刚刚完成了Mint 18 Cinnamon 64bit的干净安装,并按照上面的TheGeek61的post让Pygame再次工作。

但是当我尝试python3 setup.py build出现了一个错误:

 Traceback (most recent call last): File "setup.py", line 109, in  from setuptools import setup, find_packages ImportError: No module named 'setuptools' 

经过一番搜索,运行以下内容:

sudo pip install -U setuptools

然后允许Pygame for Python3成功安装。