Okay, so I struggled for about an hour trying to get ‘ pygame ‘ run with Python 3 on my ubuntu 11.04 machine, so I decided to write a post about it.
By default, Ubuntu ships with Python 2.7 installed, so pygame gets installed with python 2.7.
To install it with python3, do the following:
1. Open up the terminal and type the following code:
sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev
2. Then once all libraries are downloaded and installed, type:
svn co svn://seul.org/svn/pygame/trunk pygame
cd pygame
python3 setup.py build
sudo python3 setup.py install
3. That’s all! You can now run pygame with python3.
I have also updated this on the pygame website, so that no one falls into this trouble again! π
Comments on: "Installing Pygame with Python 3.2 on Ubuntu 11.04" (22)
I have been searching all over for this answer!! Thanks for putting this together.
btw…Im running Ubuntu 11.10 and it still worked just fine.
Python 3.2.2 (default, Sep 5 2011, 22:09:30)
[GCC 4.6.1] on linux2
Type “copyright”, “credits” or “license()” for more information.
>>> import pygame
>>>
Hi just wanted to thank you for pointing me into the right direction, but I ended up with an error (might be because I was using Ubuntu 11.10), have a look at this page to see the slightly reworked solution that worked for me.
http://forums.oreilly.com/topic/20635-confusion-with-installing-pygame-and-python-3/page__view__findpost__p__39168
commands I used for python 3.2:
sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev
cd /usr/local/lib/python3.2/dist-packages/
sudo svn co svn://seul.org/svn/pygame/trunk pygame
cd pygame
sudo python3 setup.py build
sudo python3 setup.py install
I like to say the libavformat-dev, libswscale-dev are also needed depencies for pygame on the 3.2 build
Not sure what the dependencies of numpy are but you will also need it installed on your 3.2 build for it function correctly. The steps are very similar to install it, except you use a git repository instead of svn. It installed without complaining about any missing depencies like last time. So I’m assuming I already I had them.
I’ve done the steps on Ubuntu 11.10 and it works.
thank you so much for the tips. π
Welcome gabirobs,
Have fun making cool stuff now. π
[…] nice useful blogposting (using Linux): https://pythonfun.wordpress.com/2011/08/08/installing-pygame-with-python-3-2-on-ubuntu-11-04/ […]
Very useful, many thanks!
ur welcome! happy to help. π
regards,
abhijit
[…] https://pythonfun.wordpress.com/2011/08/08/installing-pygame-with-python-3-2-on-ubuntu-11-04/ […]
Great, it also works on my raspberry pi.
Kernel: Linux raspberrypi 3.2.27+ (original element14 OS)
Ah! Thanks for letting us know, didn’t try that.
Cheers,
Abhijit
using 12.04 works perfectly thanks a lot π
Ur welcome Kasper. Good luck making some cool games/projects with pygame.
π
Wow, thanks alot. Even with this it took me half an hour to get everything up and running ^^;
You missed a few dependencies, so I had to find this and it improved the number I had, though it doesn’t include the Jpeg and something else.
sudo apt-get install mercurial python3-dev python3-numpy ffmpeg \
libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev \
libsdl1.2-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev
Hi John,
Glad that you finally got it working. Thank you for providing a more complete list of dependencies, gl with ur pygame adventures π
This has been great help! I don’t know how I’d ever be able to figure out how to install Pygame without finding this post. Again, you’ve been a great help to newbies. ^-^
Ur welcome π Have fun with pygame, good luck!
Thank you so so much, i can finally run pygame without windows π
Im on Lubuntu 12.10 100% Working, thanks again
If you like any combination of your computer, your sanity, or the very concept of computer programming, don’t try that in Mint.
worked also in debian jessie and ubuntu 15.10
thanks a lot !!