I struggle to make Kivy (1.11.0) use SDL2 on Ubuntu 18.04 desktop. It keeps demanding pygame but that's been deprecated and I don't want to use it for a new project.
On a fresh new Ubuntu 18.04 VM this is what I did:
~ $ 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)
With kivy installed I create a simple test.py file:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
However when I run it it fails:
~/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 <module>
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 <module>
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.
How can I force it to use SDL2? I've got the system SDL2 libs installed, installed kivy after, etc.
This is not a duplicate of similar questions asking about Windows or Mac OS-X as I'm running it on Ubuntu and the solutions don't apply.
Thanks!
egl_rpiis for a Raspberry Pi and I couldn't makex11work. That leavespygamewhich works but has been deprecated so I uninstalled it again, hoping to get it work with a non-deprecated backend. - MLupoetry add kivy- which at the back runspip3 install kivyin the virtual env. - MLu