Skip to main content

Porting Pygame 1.9 to Python 3 — wiki

Edit: Note, pygame works on python3 for some years now.

the goal

The goal is to make Pygame compatible with both Python 2.x and Python 3. So far most Python 1.9.2a0 modules build and pass their unit tests in Python 3. The corresponding examples also run. A major milestone was the release of NumPy for Python 3.1 in August, 2010. Pygame surfarray and sndarray are now ported. Some issues regarding Unicode file paths are being dealt with in the fsencoding branch. This will soon be merged back into trunk.

progress report

April 14, 2009:

python3 branch:

The build chain, and, have been modified for Unix and Windows.These can run from Python 3.0 and successfully build updated modules.

At this point the following modules have been updated: base, surface, surflock, rect, color, constant. The pygame package __init__ has also been updated. The unit test framework has been reworked enough to allow the individual unit test modules to run as stand-alone programs. The rect and color modules fully pass their unit tests.


The changes to the python3 have been merged back into the trunk. The module was also added.

April 22

The minimal requirements of getting the and examples running were met. The following modules were updated:

  • color (color.c)
  • display (display.c)
  • event (event.c)
  • font (font.c)
  • gfxdraw (gfxdraw.c)
  • image (image.c, imageext.c)
  • key (key.c)
  • local (
  • mixer (mixer.c)
  • (music.c)
  • mouse (mouse.c)
  • pygame (
  • rect (rect.c)
  • rwobject (rwobject.c)
  • sprite (
  • surface (surface.c)
  • surflock (surflock.c)
  • transform (transform.c)

The following unit tests were also update:

  • (trivial)
  • (trivial)
  • (trivial)

The following examples have been updated:


September 1, 2010

Further modules ported to Python 3.1. Though all ported modules now pass their unit tests further testing is needed.

  • draw
  • midi
  • movie
  • math
  • surfarray
  • sndarray
  • freetype

All examples except camera, overlay, vgrade, __movie and scrap_clipboard are considered ported.


  • Complete unicode file name handling (fsencoding branch), then merge back into trunk (by mid Sept/10).
  • update documentation to explain Unicode in Pygame
  • work out final solution for open Python 3 IOBase objects: how to check abstract types from C. (Sept. 1, 2010) Probably the most practical solution is to just do duck typing.
  • _movie - deferred until module is ready for release
  • scrap (does some C string stuff that makes porting difficult)
  • camera - what is the status of this module?