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: 

http://www.pygame.org/wiki/CompileUbuntu?parent=Compilation

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/_init_.py", line 95, in <module>
    from pygame.base import *
ImportError: /usr/local/lib/python3.2/dist-packages/pygame/base.cpython-32mu.so: 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://seul.org/svn/pygame/trunk pygame

And finally, build and install it:

cd pygame
python3 setup.py build
sudo python3 setup.py install 

Good luck!

Tom


PS All the information is on the pygame website. You just have to make the right combinations : )
http://www.pygame.org/wiki/svn
http://www.pygame.org/wiki/Compilation?parent=svn
2
Benjamin Poly's profile photoLeonardo Scorza's profile photoTom Gilissen's profile photoRory Brandybuck's profile photo
4 comments
 
Thanks you very much, I've spent a long time looking looking for this solution :)
Add a comment...