lucybunce
Posts: 4
Joined: Sun Feb 10, 2013 2:34 pm

pygame installation problem

Sun Feb 10, 2013 2:42 pm

I have installed pygame successfully using sudo apt-get install python-pygame

However when I use import pygame
from pygame.locals import *

I get the error;
ImportError: No module named pygame

I realise this is basic stuff but I'm a total Linux novice and been reading the User Guide for ages but can't seem to figure this one out!

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: pygame installation problem

Sun Feb 10, 2013 3:41 pm

Have you done "import pygame" beforehand?
Apple say... Monkey do !!

lucybunce
Posts: 4
Joined: Sun Feb 10, 2013 2:34 pm

Re: pygame installation problem

Sun Feb 10, 2013 3:58 pm

Well I put those two lines at the top of the python program (following exact instructions from the user guide) and it doesn't work.
Is that what you mean?

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

Re: pygame installation problem

Sun Feb 10, 2013 4:22 pm

Are you using Python 3 or Python 2? You probably only have it installed for Python 2.

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: pygame installation problem

Sun Feb 10, 2013 4:55 pm

Post your code.

Copy it from your editor (Idle, Geany, etc.) then above the edit box when you reply to this click the 'Code' button and paste your code between the tags.
It'll make it much easier to help.

Cheers.
Dave.
Apple say... Monkey do !!

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

Re: pygame installation problem

Sun Feb 10, 2013 10:45 pm

To install pygame for Python 3 under Raspbian:

Code: Select all

$ sudo apt-get install mercurial 
$ hg clone https://bitbucket.org/pygame/pygame
$ cd pygame

$ sudo apt-get install libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev 
$ sudo apt-get install libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev
$ sudo apt-get install python3-dev python3-numpy

$ python3 setup.py build 
$ sudo python3 setup.py install

lucybunce
Posts: 4
Joined: Sun Feb 10, 2013 2:34 pm

Re: pygame installation problem

Mon Feb 11, 2013 10:22 am

Thank you!

I will try later when I get the Pi out again.

lucybunce
Posts: 4
Joined: Sun Feb 10, 2013 2:34 pm

Re: pygame installation problem

Mon Feb 11, 2013 5:05 pm

Thanks very much - it worked!

Initially mercurial didn't install correctly so hg wasn't found. I did an update then it worked well.

WoodyP
Posts: 8
Joined: Mon Apr 15, 2013 10:42 pm

Re: pygame installation problem

Mon Apr 15, 2013 10:55 pm

Thanks Croston for the install procedure for pygame on python3. I appreciate it!! :P

CoolCalProgrammer_88
Posts: 3
Joined: Thu Jan 30, 2014 4:31 pm

Re: pygame installation problem

Sun Feb 09, 2014 12:30 pm

THANK YOU IVE BEEN SEARCHING FOR AGES !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :) :D :D :D :D :D :D :D :D :D :D :D :)

dgordon42
Posts: 741
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: pygame installation problem

Sun Feb 09, 2014 8:12 pm

Just to say thanks for this again.

If anyone is thinking of doing this, the whole process takes the best part of an hour.

Dave.

Roland Boss
Posts: 2
Joined: Sat Feb 15, 2014 6:32 pm

Re: pygame installation problem

Sat Feb 15, 2014 6:41 pm

croston wrote:To install pygame for Python 3 under Raspbian:

Code: Select all

$ sudo apt-get install mercurial 
$ hg clone https://bitbucket.org/pygame/pygame
$ cd pygame

$ sudo apt-get install libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev 
$ sudo apt-get install libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev
$ sudo apt-get install python3-dev python3-numpy

$ python3 setup.py build 
$ sudo python3 setup.py install
Hi, a newbie here. I'm having trouble with this as well. I've got IDLE3 and python 3.2.2. Tried out the bat and ball game from the MagPi mag issue 1 but although I've got pygame installed the game gives me an error. For this piece of code above , do I need to be connected to the internet to do this, as I see an http// thingy there. (Excuse my lack of technical vocabulary!). Thanks in advance for any help.

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: pygame installation problem

Sat Feb 15, 2014 9:26 pm

Yes, your RPi needs a working internet connection to be able to succesfully run the apt-get install and hg clone commands.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

Roland Boss
Posts: 2
Joined: Sat Feb 15, 2014 6:32 pm

Re: pygame installation problem

Sun Feb 16, 2014 2:16 pm

DeeJay wrote:Yes, your RPi needs a working internet connection to be able to succesfully run the apt-get install and hg clone commands.

Thanks for the info. Cheers

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: pygame installation problem

Sun Feb 16, 2014 4:30 pm

I gave a specific answer to a specific question. But I'm not sure it helps you with your MagPi query?

You said:
I've got IDLE3 and python 3.2.2. Tried out the bat and ball game from the MagPi mag issue 1 but although I've got pygame installed the game gives me an error.
Well if you've got pygame installed you don't need to be concerned with the instructions you supplied as a quote, because they are about getting pygame installed, not about using it in a python script.

So, what is the error you get? Is it something like:

Code: Select all

ImportError: No module named pygame
If so, then you don't have pygame installed for python3. (Note that for practical purposes python (ie. Python 2.7.3) and python3 are separately installed and supported languages, and have their own supporting libraries and modules. If you are checking around on your system for any instance of pygame it is probably the python2 version which is installed in Raspbian by default that you are finding.

In case you haven't tried - although the MagPi article says 'tested with Python 3.2.2', it actually runs without complaint under Python 2.7.3 - but I use my RPi 'headless' (without Graphics) so I can't say that it runs faultlessly.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

aasquith
Posts: 1
Joined: Thu Sep 04, 2014 10:06 pm

Re: pygame installation problem

Thu Sep 04, 2014 10:10 pm

I'm getting an error when I use the last two commands as follows:


python3 setup.py build


WARNING, No "Setup" File Exists, Running "config.py"
Using UNIX configuration...


Hunting dependencies...
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
WARNING: "sdl-config" failed!
/bin/sh: 1: smpeg-config: not found
/bin/sh: 1: smpeg-config: not found
/bin/sh: 1: smpeg-config: not found
WARNING: "smpeg-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.

Any ideas why?

maximoose
Posts: 22
Joined: Thu Sep 18, 2014 1:10 am

Re: pygame installation problem

Fri Sep 19, 2014 12:24 am

I have tried the method suggested by croston above, but with no success, everywhere I go I see that method appearing and reappearing over and over again, does anyone else have another method to install it by. Your help is greatly appreciated.

When I type:
[email protected] ~ $ hg clone https://bitbucket.org/pygame/pygame

I get:

destination directory: pygame
abort: destination 'pygame' is not empty

Sleep Mode zZ
Posts: 319
Joined: Sun Aug 19, 2012 5:56 am
Location: Finland

Re: pygame installation problem

Fri Sep 19, 2014 8:16 am

maximoose wrote:I have tried the method suggested by croston above, but with no success, everywhere I go I see that method appearing and reappearing over and over again, does anyone else have another method to install it by. Your help is greatly appreciated.

When I type:
[email protected] ~ $ hg clone https://bitbucket.org/pygame/pygame

I get:

destination directory: pygame
abort: destination 'pygame' is not empty
That means that you already have that directory (folder) there. Probable explanation: You have already done that step before. You could delete the folder and then try again from the start or assume that you have already done the cloning step (correctly )and continue with the next command in the instructions. Maybe the first option is safer in case there is been some problem with the cloning when you did that before.

This is assuming that you have not created a pygame directory into your home directory for some other reason, e.g. to hold your own pygame games. In that case don't delete the directory but use a different directory for Croston's procedure of for your pygame games.

SageDesign
Posts: 16
Joined: Wed Jan 09, 2013 2:19 pm

Re: pygame installation problem

Wed Mar 18, 2015 2:07 pm

This worked for me, thank you. There were a couple of hiccups, but easily cured.

evanpeeair
Posts: 2
Joined: Sat Apr 18, 2015 3:06 am

Re: pygame installation problem

Sat Apr 18, 2015 3:10 am

aasquith wrote:I'm getting an error when I use the last two commands as follows:


python3 setup.py build


WARNING, No "Setup" File Exists, Running "config.py"
Using UNIX configuration...


Hunting dependencies...
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
WARNING: "sdl-config" failed!
/bin/sh: 1: smpeg-config: not found
/bin/sh: 1: smpeg-config: not found
/bin/sh: 1: smpeg-config: not found
WARNING: "smpeg-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.

Any ideas why?
I got the same error, I had to add
sudo apt-get update&&
to the first get to update the libraries.

Code that worked for me:

Code: Select all

$ sudo apt-get install mercurial 
$ hg clone https://bitbucket.org/pygame/pygame
$ cd pygame

$ sudo apt-get update&&sudo apt-get install libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev 
$ sudo apt-get install libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev
$ sudo apt-get install python3-dev python3-numpy

$ python3 setup.py build 
$ sudo python3 setup.py install
Cheers.

User avatar
bonzadog
Posts: 205
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: pygame installation problem

Tue Sep 19, 2017 3:15 pm

python3 setup.py build cause problems with rights,
sudo python3 setup.py build run but with warnings.

Return to “Python”

Who is online

Users browsing this forum: pootle and 18 guests