Shared publicly  - 
How to install Pygame for use with Python 3.x on Ubuntu 12.04?

Today, I had some trouble installing pygame for use with python 3.2. Pygame for python 2.7 is easy: you can get that through apt-get. For use with python 3.x you need to build pygame from source. I followed the instructions from the pygames website:

All seemed to work just fine, until I tried to use the new module:

>>> import pygame

This raised the following error message:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pygame
  File "/usr/local/lib/python3.2/dist-packages/pygame/", line 95, in <module>
    from pygame.base import *
ImportError: /usr/local/lib/python3.2/dist-packages/pygame/ undefined symbol: PyCObject_Check

It took me some time to find a solution, but I finally got everything working just fine. Because many others seem to be struggling with the same issue - and some even say it's not possible! - I thought it might be useful to share my solution.

First, install the following dependencies:

sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python3-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev

Next, download the latest edition of pygame from the subversion repository:

svn co svn:// pygame

And finally, build and install it:

cd pygame
python3 build
sudo python3 install 

Good luck!


PS All the information is on the pygame website. You just have to make the right combinations : )
Benjamin Poly's profile photoThomas Chilinski's profile photoArjan Dijkstra's profile photoEmmanuel Doumenc's profile photo
Thanks you very much, I've spent a long time looking looking for this solution :)
:( a typical day. ffmpeg did not install.
"E: Package 'ffmpeg' has no installation candidate"
Went to Git for ffmpeg. The ReadME contains no instructions.
Cloned the Git anyway. found a configure script. Iv'e seen this be4!
$ ./configure
" yasm/nasm not found or too old. Use --disable-yasm for a crippled build."
did a google search on ffmpeg and found a way off installing it with yum
$sudo apt-get install yum
went back into my virturalenv
$sudo yum install yasm
" There are no enabled repos."

"What was i trying to install again?"

"Gets up and searches for a cup of coffee."
Thank you very much, finally got it to work this way. 
Add a comment...