安装PyGame,Python2.7和3.4之间的区别?
我想使用PyGame模块,当然,我开始安装它。因为python的默认版本是2.7,所以我下载了(更早的)Python3.4并一直在使用它。在安装PyGame时,我在终端中输入以下命令:安装PyGame,Python2.7和3.4之间的区别?,python,python-2.7,python-3.x,pygame,pip,Python,Python 2.7,Python 3.x,Pygame,Pip,我想使用PyGame模块,当然,我开始安装它。因为python的默认版本是2.7,所以我下载了(更早的)Python3.4并一直在使用它。在安装PyGame时,我在终端中输入以下命令:python3.4-m pip install hg+http://bitbucket.org/pygame/pygame <pre> $ sudo apt-get install mercurial $ hg clone https://bitbucket.org/pygame/pygame $
python3.4-m pip install hg+http://bitbucket.org/pygame/pygame
<pre>
$ sudo apt-get install mercurial
$ hg clone https://bitbucket.org/pygame/pygame
$ cd pygame
$ sudo apt-get install libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
$ sudo apt-get install libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev
$ sudo apt-get install python3-dev python3-numpy
$ python3 setup.py build
$ sudo python3 setup.py install
</pre>
正如您可能看到的,我正在使用pip
和mercurial
来帮助您
尝试使用上述命令安装PyGame时,安装似乎开始,但返回以下错误:
WARNING, No "Setup" File Exists, Running "config.py"
Using Darwin configuration...
/bin/sh: smpeg-config: command not found
/bin/sh: smpeg-config: command not found
/bin/sh: smpeg-config: command not found
/bin/sh: /usr/X11R6/bin/freetype-config: No such file or directory
/bin/sh: /usr/X11R6/bin/freetype-config: No such file or directory
/bin/sh: /usr/X11R6/bin/freetype-config: No such file or directory
WARNING: "smpeg-config" failed!
WARNING: "/usr/X11R6/bin/freetype-config" failed!
Hunting dependencies...
SDL : found 1.2.15
Framework SDL not found
FONT : found
Framework SDL_ttf not found
IMAGE : found
Framework SDL_image not found
MIXER : found
Framework SDL_mixer not found
SMPEG : not found
Framework smpeg not found
Framework CoreMIDI found
Framework QuickTime found
PNG : found
JPEG : found
PORTMIDI: found
FREETYPE: not found
AVFORMAT: not found
SWSCALE : not found
If you get compiler errors during install, doublecheck
the compiler flags in the "Setup" file.
Continuing With "setup.py"
Skipping module _numericsurfarray for Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] build.
Skipping module _numericsndarray for Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] build.
no previously-included directories found matching '*/CVS'
no previously-included directories found matching '*/*/CVS'
我以前通过终端安装过这些依赖项,但它们是否只针对Python2.7安装,而python3.4不识别它们?(我不知道这是否是一个有效的建议,因为这类东西不是我的专业领域)
我进入了Python3.4(交互模式)并导入了PyGame(但我想我无法使用所有模块的功能)
但是,当我使用默认python(2.7)在终端上运行相同的命令时,它会成功安装:
sudo pip install hg+http://bitbucket.org/pygame/pygame
Password:
Collecting hg+http://bitbucket.org/pygame/pygame
Cloning hg http://bitbucket.org/pygame/pygame to /tmp/pip-q1scmd-build
Installing collected packages: pygame
Running setup.py install for pygame
Successfully installed pygame-1.9.2a0
有人能提出造成这种差异的原因吗?我想我可以在制作游戏时使用python2.7,但在同一种语言的两个版本之间切换仍然很乏味。这对我来说很有用:
$sudo apt获取安装mercurial
$hg克隆https://bitbucket.org/pygame/pygame
$cd pygame
$sudo apt get安装libsdl dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
$sudo apt get安装libsmpeg dev libportmidi dev libavformat dev libswscale dev
$sudo apt get安装python3 dev python3 numpy
$python3 setup.py build
$sudo python3 setup.py安装