Page 1 of 1

Can't get Python to run with Pygame

Posted: Sun Jul 01, 2012 11:04 am
by oobtim
:evil: Been very frustrating over the last week.

I have experience with C++ so I have been fiddling with Python to try learning a new language but keeping hitting a wall. I've been trying to run Python (both on command line and through JPE on the Debian OS) to run the example 'bat and ball' program in the Magpi issue 2 magazine but it refuses to run.

When checking using JPE it produces an error message:
error importing pygame: name 'color' is not defined
On the command line I get errors with ALSA to do with card 0 e.g.:
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
A simple"Hello World" runs fine but this one kicks up a fuss. Any ideas what's going wrong?

Re: Can't get Python to run with Pygame

Posted: Mon Jul 02, 2012 6:34 am
by texy
Which version of python are you running? Isn't Pygame only compatable with python 2, but not 3 ?

T.

Re: Can't get Python to run with Pygame

Posted: Mon Jul 02, 2012 6:58 am
by KenT
Well worth updating to Wheezy Beta. That has pygame installed for python 2.7, maybe for 3 as well, also has a set of pygame based games with source and a pygame tutorial accessible from the desktop. Analogue and hdmi sound works with pygame in wheezy.

Re: Can't get Python to run with Pygame

Posted: Mon Jul 02, 2012 6:50 pm
by tcstyle
I couldn't find any "bat and ball" example in the 2nd MagPi issue to check back, but the problem with errors like that
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
seems to be missing sound drivers in squeeze.
Look at this to install the sound module: http://www.chrisnewland.com/solved-no-s ... indows-244

Solved those issues for me.

Re: Can't get Python to run with Pygame

Posted: Mon Jul 02, 2012 7:26 pm
by oobtim
Sorry my mistake, issue 1 :S

I'm running Python 2.6.6 if that helps. I aim to try out wheezy, puppy etc. once my order of sd cards comes in the post. I was going to try them all out then choose which is best for me.

I'll give the sound driver update a go and see if I can start listening to music.

BTW certainly recommend using Dillo as a web browser. Very basic but it works good enough for me to type this out on the Pi :)

Re: Can't get Python to run with Pygame

Posted: Fri Jul 06, 2012 8:55 am
by oobtim
Sorted it out. Tried Debian Wheezy worked straight away :D

Re: Can't get Python to run with Pygame

Posted: Tue Jul 10, 2012 5:53 am
by antiloquax
Hi,
Sorry, I've only just seen this!
Glad to hear you got the bat and ball program working on your Pi.

Just for the record, I use Python 3.1.4 with Pygame. Everything works, but I did have to compile it myself (I'm on Arch).

There should be a more interesting Python / Pygame game in issue 4 (if I can make it short enough to fit on two pages!)
antiloquax