Kivy SDL2 Dependency

raw JSON →
0.8.0 verified Fri May 01 auth: no python

Repackaged binary dependency of Kivy providing SDL2 libraries. Version 0.8.0 is the latest release. Release cadence is irregular, tied to Kivy packaging updates.

pip install kivy-deps-sdl2
error ImportError: No module named 'sdl2'
cause Trying to import sdl2 directly, but kivy-deps-sdl2 does not provide a Python module by that name.
fix
Do not import sdl2; instead use Kivy's core modules like from kivy.core.window import Window.
error OSError: incompatible library version
cause Conflicting SDL2 libraries from another package (e.g., PySDL2, pysdl2).
fix
Uninstall any other SDL2-related packages and ensure only kivy-deps-sdl2 is installed.
gotcha kivy-deps-sdl2 is not imported directly; it only provides the SDL2 binaries. Attempting to import sdl2 will fail.
fix Install kivy-deps-sdl2 and use Kivy's Window class.
gotcha Conflicts may arise if other SDL2 packages (like PySDL2) are installed. This package relies on a specific SDL2 version.
fix Uninstall conflicting packages or use a virtual environment.
deprecated Kivy 2.2+ uses SDL2 by default; kivy-deps-sdl2 may become deprecated if Kivy bundles its own SDL2.
fix Use Kivy's built-in dependencies when available.

Basic Kivy app that uses SDL2 as the window provider via kivy-deps-sdl2.

import kivy
kivy.require('2.1.0')
from kivy.app import App
from kivy.uix.label import Label

class MyApp(App):
    def build(self):
        return Label(text='Hello, Kivy with SDL2')

if __name__ == '__main__':
    MyApp().run()