Setting up Kivy with SDL2 and Python 3 on Ubuntu with virtualenv


Kivy has traditionally used Pygame which is a python wrapper for SDL 1.2. However setting up Kivy with Pygame is a bit annoying and since Pygame is very old and unmaintained you don't want to use it anyway.

Kivy 1.9.1 however has a direct interface for SDL2 which is super modern and awesome!

To use it you should do something like this:

  • Check that your Virtualenv setup is up to date: Blog post: Upgrading python virtualenv to the latest version on Ubuntu
  • Install some development headers:
    sudo apt-get install python3-dev libsdl2-ttf-dev libsdl2-net-dev libsdl2-mixer-dev libsdl2-image-dev libsdl2-gfx-dev libsdl2-dev
  • Install Kivy 1.9.1
    virtualenv --no-site-packages -p python3 kivyinstall
    . kivyinstall/bin/activate
    pip install cython
    pip install git+

Now if you run python ./kivyinstall/share/kivy-examples/tutorials/pong/ you should see something like this:

[INFO ] [Logger ] Record log in /home/ernst/.kivy/logs/kivy_15-07-19_8.txt
[INFO ] [Kivy ] v1.9.1-dev
[INFO ] [Python ] v3.4.3 (default, Mar 26 2015, 22:03:40)
[GCC 4.9.2]
[INFO ] [Factory ] 176 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO ] [GL ] OpenGL version <b'3.0 Mesa 10.7.0-devel (git-8c8a71f 2015-07-19 vivid-oibaf-ppa)'>
[INFO ] [GL ] OpenGL vendor <b'X.Org'>
[INFO ] [GL ] OpenGL renderer <b'Gallium 0.4 on AMD BARTS'>
[INFO ] [GL ] OpenGL parsed version: 3, 0
[INFO ] [GL ] Shading version <b'1.30'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <16>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Text ] Provider: sdl2
[INFO ] [Base ] Start application main loop
[INFO ] [GL ] NPOT texture support is available
[INFO ] [Base ] Leaving application in progress...
Current rating: 3


There are currently no comments

New Comment


required (not published)


Recent Tweets

Recent Posts







RSS / Atom