PyGame, Python 3.1 and Debian


8 posts
by Bollard » Sat Apr 21, 2012 4:11 pm
Hey there,

I've been messing around with PyGame for a little while before my Pi arrived, but all the prior work I've done has been written in Python3 (and PyGame 1.9). As the RPi came with Python 2.6 on by default (as well as Pygame 1.8), I went ahead and got Python 3.1 fron Synaptic.

However, when I try and run my old Pygame games from IDLE for Python 3.1, it tells me there is no module to import called Pygame. My only prior Linux experiences is very infequent use of the latest Ubuntu, and so I'm not really sure what's up here. With Windows there's a separate version of Pygame you have to install depending on your Python version, is it just that the Linux Pygame only supports Python 2?

Thanks for any help in advance.
User avatar
Posts: 18
Joined: Tue Apr 17, 2012 8:11 pm
by croston » Sat Apr 21, 2012 5:02 pm
I have Python 3.2 and PyGame running under Debian. You have to build it from source though. The instructions are here :
http://elinux.org/RPi_Debian_Python3

I suspect (without checking) that your problem is that PyGame in the Debian repository is for Python 2.6.
User avatar
Posts: 465
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
by rurwin » Sat Apr 21, 2012 5:08 pm
Pygame is a library and is sits inside the python directories. So when you installed a new version of Python gthat probably got installed somewhere else and it no longer has the pyGame library in it.

I believe that the binary Unix downloads are only for Python 2, so you will need to install from source code. Download the Pygame source from http://www.pygame.org, unzip it, start a command-prompt and navigate to the unzipped directory with setup.py in it and type "python setup.py". See http://www.pygame.org/install.html for details.
User avatar
Forum Moderator
Forum Moderator
Posts: 2935
Joined: Mon Jan 09, 2012 3:16 pm
by Bollard » Sat Apr 21, 2012 5:19 pm
Thanks for the responses guys, I'll give it a go when I have my Pi connected to the interwebs again.
User avatar
Posts: 18
Joined: Tue Apr 17, 2012 8:11 pm
by Bollard » Mon Apr 23, 2012 5:35 pm
I'm getting an error stopping me from building saying not enough space on device, any idea why? There's like 200mb free on my card (I can't fix the partition thing atm cause I haven't got an SD card reader attached to anything which can run Gparted cause my laptop's disc drive is borked.) Otherwise I'd have like 5.5gb free. But surely 200mb is enough for Pygame...
User avatar
Posts: 18
Joined: Tue Apr 17, 2012 8:11 pm
by Bollard » Mon Apr 23, 2012 5:37 pm
Hmm just ran it with sudo at the start and it finished in like 15 seconds. The wiki says 15 mins... Just ran the install too and it seems to have worked. Fingers crossed.
User avatar
Posts: 18
Joined: Tue Apr 17, 2012 8:11 pm
by Bollard » Mon Apr 23, 2012 5:55 pm
Well, that completely broke my Debian Image. Somehow. I tried to run IDLE 3 but it wouldn't do anything, restarted the Pi and now it can't find any programs. Restarted again and now it fails to run "startx"

ARGH
User avatar
Posts: 18
Joined: Tue Apr 17, 2012 8:11 pm
by cubusaddendum » Sun Aug 12, 2012 6:18 am
FWIW I followed the same instructions just now and it worked fine, save for two files that needed tweaking to remove the typical python2->python3 syntax errors:

/usr/local/lib/python3.2/dist-packages/python/pygame

./examples/movieplayer.py
./tests/test_utils/png.py
User avatar
Posts: 1
Joined: Sun Aug 05, 2012 7:02 pm
Location: Brighton, UK