понедельник, 4 ноября 2013 г.

Запуск pygame под python3

http://www.python-forum.org/viewtopic.php?f=25&t=2716:


----------------------------

Pygame python3.x Installation

Postby metulburr » Thu Apr 25, 2013 2:58 am
python2.x:
sudo apt-get install python-pygame
python3.x:
ImportError: /usr/local/lib/python3.2/dist-packages/pygame/base.cpython-32mu.so: undefined symbol: PyCObject_Check

1) Download pygame 1.9.2 pre and extract it
https://launchpad.net/debian/experiment ... rig.tar.gz

2) if you already installed 1.9.1, and installed it under python3.x, then remove it:
in directory: ( replace python3.2, with whichever version you have
/usr/local/lib/python3.2/dist-packages
execute these two commands:
sudo rm -r pygame
sudo rm pygame-1.9.1release.egg-info


3) install python3 pygame dependencies:

sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev

for example if you do not download python3.dev you will get this error:
src/pygame.h:75:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'i686-linux-gnu-gcc' failed with exit status 1
sudo apt-get install python3-dev

4) change directory to the newly donwloaded/extracted pygame directory and execute:
sudo python3 setup.py install


5)
Hunting dependencies...
SDL     : found 1.2.14
FONT    : found
IMAGE   : found
MIXER   : found
SMPEG   : found 0.4.5
PNG     : found
JPEG    : found
SCRAP   : found
PORTMIDI: found
PORTTIME: found
AVFORMAT: not found
SWSCALE : not found
FREETYPE: found 2.4.8


Warning, some of the pygame dependencies were not found. Pygame can still
compile and install, but games that depend on those missing dependencies
will not run. Would you like to continue the configuration? [Y/n]:

will display that some games may not work, etc. yatta yatta, hit y for yes. Although make sure SDL is found, MPEG, IMAGE, FONT. i have not yet came across a game that i couldnt run, yet, with these two that were not found.

6) confirm installation:
metulburr@ubuntu:~$ python3
Python 3.2.3 (default, Oct 19 2012, 20:10:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>>