User avatar
Bollard
Posts: 18
Joined: Tue Apr 17, 2012 8:11 pm

Python 3(.2.3) and Pygame on Rasbian Wheezy

Tue Jul 31, 2012 3:52 pm

As the title says I'm using the latest Rasbian Wheezy image, and it only comes with Pygame installed for Python 2 (annoyingly.) I have a game I've written in Python 3 (.1.3 to be precise), and I want to see if/how well it runs on the Pi.

Now, as far as I'm aware there is no easy way for me to get Pygame working with Python 3, and I believe I will have to compile it from source? I'm a bit of a Unix noob, so could someone explain to me the steps I might need to follow to do this, or how you did it if you have done another way?

I grabbed the source for Pygame 1.9.1 from here: http://www.pygame.org/download.shtml
and read the installation guide here: http://www.pygame.org/install.html
but the Unix compiling bit went over my head. I'm not used to compiling stuff myself.

Any help will be greatly appreciated, thanks.

User avatar
croston
Posts: 702
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: Python 3(.2.3) and Pygame on Rasbian Wheezy

Tue Jul 31, 2012 5:19 pm

To get PyGame installed for Python 3.2 under Raspbian, follow the instructions in the PyGame section here:

http://elinux.org/RPi_Debian_Python3

You will also need to do

Code: Select all

sudo apt-get install python3-dev python3-numpy
before starting. Ignore everything else on that page!

User avatar
Bollard
Posts: 18
Joined: Tue Apr 17, 2012 8:11 pm

Re: Python 3(.2.3) and Pygame on Rasbian Wheezy

Tue Jul 31, 2012 5:29 pm

croston wrote:To get PyGame installed for Python 3.2 under Raspbian, follow the instructions in the PyGame section here:

http://elinux.org/RPi_Debian_Python3

You will also need to do

Code: Select all

sudo apt-get install python3-dev python3-numpy
before starting. Ignore everything else on that page!
Ah thanks! I was following that guide, however I hadn't done the thing you suggested with python3-dev.

I ended up getting an error saying it couldn't find Python.h or something when I tried to build, is it likely that came up because I didn't run the install you suggested?

User avatar
croston
Posts: 702
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: Python 3(.2.3) and Pygame on Rasbian Wheezy

Tue Jul 31, 2012 5:32 pm

That is exactly what will happen if you don't install python3-dev first. Have fun!

User avatar
Bollard
Posts: 18
Joined: Tue Apr 17, 2012 8:11 pm

Re: Python 3(.2.3) and Pygame on Rasbian Wheezy

Wed Aug 01, 2012 8:10 am

croston wrote:That is exactly what will happen if you don't install python3-dev first. Have fun!
Ah thanks! I'll give it a go when I get back after my driving lesson.

Oh and a note to anyone else who is trying this, if you try and do the libsdl installs as described on that wiki page under Pygame, quite a few of them will fail because of 404 errors. After they fail, re-run them with "--get-missing" affixed to the end and it'll fix itself.

User avatar
Bollard
Posts: 18
Joined: Tue Apr 17, 2012 8:11 pm

Re: Python 3(.2.3) and Pygame on Rasbian Wheezy

Wed Aug 01, 2012 1:07 pm

I can't see a way to edit so I'mma just double post, but went through and did the python3-dev install and now have working Pygame with Python 3! Thanks!

Shame I have to run my game outside of X or it chugs so bad haha.

JustSomeGuyTN
Posts: 2
Joined: Tue Mar 31, 2015 1:11 am

Re: Python 3(.2.3) and Pygame on Rasbian Wheezy

Tue Mar 31, 2015 3:14 am

I have tried following the directions mentioned including the part not on the debian python3 page. But I still get this:

Code: Select all

>>> import pygame
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pygame
ImportError: No module named pygame
>>>
Also I've seen a YouTube video claiming that pygame for Python3 is now included in raspian. Is this true? I haven't really started on my project yet so I'm wondering if I should just remake my SD card with a new image.

Edit:
Nevermind, I redid the process and I think I was missing some dependencies in the build. It all seems to work now.

algelman
Posts: 1
Joined: Sun Oct 02, 2016 10:14 pm

Re: Python 3(.2.3) and Pygame on Rasbian Wheezy

Sun Oct 02, 2016 10:24 pm

I folowed the script successfully however when I tried " python3 setup.py build"it failed because it could not find the module "setuptools". How do I get it?

Return to “Python”