oobtim
Posts: 15
Joined: Sun Jul 01, 2012 10:52 am
Location: Chippenham, UK

Can't get Python to run with Pygame

Sun Jul 01, 2012 11:04 am

: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?

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Can't get Python to run with Pygame

Mon Jul 02, 2012 6:34 am

Which version of python are you running? Isn't Pygame only compatable with python 2, but not 3 ?

T.
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

KenT
Posts: 758
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
Contact: Website

Re: Can't get Python to run with Pygame

Mon Jul 02, 2012 6:58 am

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.
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from http://pipresents.wordpress.com

tcstyle
Posts: 10
Joined: Mon Jul 02, 2012 6:47 pm
Location: Hannover, Germany
Contact: Website

Re: Can't get Python to run with Pygame

Mon Jul 02, 2012 6:50 pm

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.

oobtim
Posts: 15
Joined: Sun Jul 01, 2012 10:52 am
Location: Chippenham, UK

Re: Can't get Python to run with Pygame

Mon Jul 02, 2012 7:26 pm

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 :)

oobtim
Posts: 15
Joined: Sun Jul 01, 2012 10:52 am
Location: Chippenham, UK

Re: Can't get Python to run with Pygame

Fri Jul 06, 2012 8:55 am

Sorted it out. Tried Debian Wheezy worked straight away :D

antiloquax
Posts: 406
Joined: Sun Nov 20, 2011 11:37 am
Contact: Website

Re: Can't get Python to run with Pygame

Tue Jul 10, 2012 5:53 am

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

Return to “Python”