Universe存储库中提供了一个适用于Python2的软件包(python-pygame)。但是,我想通读Invent with Python一书中的教程。通过SPM(Synaptic),我找不到Python3的pygame资源。
另外,我查看了Pygame网站,还不清楚Pygame是否可用于Python3(尽管书中指出了)。
有人可以帮助我解决我的困境吗?
Universe存储库中提供了一个适用于Python2的软件包(python-pygame)。但是,我想通读Invent with Python一书中的教程。通过SPM(Synaptic),我找不到Python3的pygame资源。
另外,我查看了Pygame网站,还不清楚Pygame是否可用于Python3(尽管书中指出了)。
有人可以帮助我解决我的困境吗?
Answers:
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的发布,以使Pygame再次正常工作。
但是当我尝试python3 setup.py build
出一个错误:
Traceback (most recent call last):
File "setup.py", line 109, in <module>
from setuptools import setup, find_packages
ImportError: No module named 'setuptools'
搜索后,运行以下命令:
sudo pip install -U setuptools
然后允许Pygame for Python3成功安装。
IMPORTANT_MOVED.txt
似乎...重要。所以我将svn...
线改为hg clone https://bitbucket.org/pygame/pygame