title: Python Kivy won't use SDL2, insists on using pygame
body: <p>I struggle to make <a href="https://kivy.org" rel="nofollow noreferrer"><strong>Kivy</strong></a> (1.11.0) use <strong>SDL2</strong> on <strong>Ubuntu 18.04</strong> desktop. It keeps demanding <code>pygame</code> but that's been deprecated and I don't want to use it for a new project.</p>
  
  <p>On a fresh new <em>Ubuntu 18.04 VM</em> this is what I did:</p>
  
  <pre class="lang-sh prettyprint-override"><code>~ $ sudo apt install libsdl2-dev libsdl2-image-dev mesa-common-dev python3-pip python3-venv
  ~ $ pip3 install --user poetry
  ~ $ poetry new kivytest
  ~ $ cd kivytest
  
  ~/kivytest $ poetry add kivy pillow
  Creating virtualenv kivytest-sUhjZQq9-py3.6 in ~/.cache/pypoetry/virtualenvs
  Using version ^1.11.1 for kivy
  Using version ^7.0.0 for pillow
  
  Updating dependencies
  Resolving dependencies... (2.2s)
  
  Writing lock file
  
  
  Package operations: 20 installs, 0 updates, 0 removals
  
    - Installing certifi (2019.11.28)
    - [...]
    - Installing pillow (7.0.0)
    - Installing kivy (1.11.1)
  </code></pre>
  
  <p>With <code>kivy</code> installed I create a simple <code>test.py</code> file:</p>
  
  <pre class="lang-py prettyprint-override"><code>from kivy.app import App
  from kivy.uix.button import Button
  
  class TestApp(App):
      def build(self):
          return Button(text='Hello World')
  
  TestApp().run()
  </code></pre>
  
  <p>However when I run it it fails:</p>
  
  <pre class="lang-sh prettyprint-override"><code>~/kivytest $ export KIVY_GL_BACKEND="sdl2"
  
  ~/kivytest $ poetry run python3 ./test.py
  [INFO   ] [Logger      ] Record log in ~/.kivy/logs/kivy_20-03-29_6.txt
  [INFO   ] [Kivy        ] v1.11.1
  [INFO   ] [Kivy        ] Installed at "~/.cache/pypoetry/virtualenvs/kivytest-sUhjZQq9-py3.6/lib/python3.6/site-packages/kivy/__init__.py"
  [INFO   ] [Python      ] v3.6.9 (default, Nov  7 2019, 10:44:02) 
  [GCC 8.3.0]
  [INFO   ] [Python      ] Interpreter at "~/.cache/pypoetry/virtualenvs/kivytest-sUhjZQq9-py3.6/bin/python3"
  [INFO   ] [Factory     ] 184 symbols loaded
  [INFO   ] [Image       ] Providers: img_tex, img_dds, img_pil, img_gif (img_pygame, img_ffpyplayer ignored)
  [INFO   ] [Text        ] Provider: pil(['text_pygame'] ignored)
  [CRITICAL] [Window      ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
  egl_rpi - ImportError: cannot import name 'bcm'
    File "~/.cache/pypoetry/virtualenvs/kivytest-sUhjZQq9-py3.6/lib/python3.6/site-packages/kivy/core/__init__.py", line 63, in core_select_lib
      fromlist=[modulename], level=0)
    File ".../kivy/core/window/window_egl_rpi.py", line 12, in &lt;module&gt;
      from kivy.lib.vidcore_lite import bcm, egl
  
  pygame - ModuleNotFoundError: No module named 'pygame'
    File ".../kivy/core/__init__.py", line 63, in core_select_lib
      fromlist=[modulename], level=0)
    File ".../kivy/core/window/window_pygame.py", line 13, in &lt;module&gt;
      import pygame
  
  x11 - ModuleNotFoundError: No module named 'kivy.core.window.window_x11'
    File ".../kivy/core/__init__.py", line 63, in core_select_lib
      fromlist=[modulename], level=0)
  
  [CRITICAL] [App         ] Unable to get a Window, abort.
  </code></pre>
  
  <p>How can I force it to <strong>use SDL2</strong>? I've got the system SDL2 libs installed, installed <code>kivy</code> <em>after</em>, etc.</p>
  
  <p>This is <strong>not a duplicate</strong> of similar questions asking about <em>Windows</em> or <em>Mac OS-X</em> as I'm running it on Ubuntu and the solutions don't apply.</p>
  
  <p>Thanks!</p>