这个帖子不仅涉及 pygame,还涉及 livewires。我遵循了第一个答案关联但是当我写这个命令时:sudo pip install pygame
,我收到一条错误消息:
Could not find any downloads that satisfy the requirement pygame.
Some externally hosted files were ignored (use --allow-external pygame to allow).
Cleaning up...
No distributions at all found for pygame
Storing debug log for failure in /home/cooldudeabhi/.pip/pip.log
如何修复它们。另外,我正在使用蟒蛇3.4。请帮我安装两个模块:Pygame 和 livewires。
答案1
打开终端并输入以下命令。它将安装pygame
在您的系统上:
sudo apt-get install mercurial python3-pip libfreetype6-dev
sudo apt-get build-dep python-pygame
sudo pip3 install hg+http://bitbucket.org/pygame/pygame
关于livewires
,似乎这个包仅适用于 python2.x,因为我在运行时出现以下错误sudo pip3 install livewires
:
Running setup.py install for livewires
File "/usr/local/lib/python3.4/dist-packages/livewires/beginners.py", line 201
raise ExBadParameters, "colour must be from Colour class"
^
SyntaxError: invalid syntax
File "/usr/local/lib/python3.4/dist-packages/livewires/boards.py", line 239
if k <> l and k <> -l:
^
SyntaxError: invalid syntax
File "/usr/local/lib/python3.4/dist-packages/livewires/games.py", line 110
raise GamesError, "Cannot have more than on Screen object"
^
SyntaxError: invalid syntax
当你想用 python3 解释器运行 python2 代码时,这样的错误相当常见。
更新:似乎可以在上述文件上运行 2to3 并成功安装livewires
。
- 下载并解压LiveWires-2.1.tar.gz来自 pypi。
cd LiveWires-2.1
2to3 -w livewires/*
sudo python3 setup.py install
答案2
有一个 Ubuntu 软件包python-pygame
。您可以使用图形应用程序安装它软件或者在命令行上
sudo apt-get install python-pygame