kivy: Buster RPi4B unable to find valuable Window provider from Desktop-less console
After logging on the Raspberry Pi 4B to the command line (using raspi-config boot to CLI), cannot execute kivy because of critical error when attempting to use any kivy Window provider: egl_rpi, sdl2, pygame, or x11. This issue lists the attempts and results of each of these Window providers. These providers are listed on the following page:
https://kivy.org/doc/stable/guide/environment.html
KIVY_WINDOW Implementation to use for creating the Window Values: sdl2, pygame, x11, egl_rpi
Versions
- Python: 3.7.3
- OS: Raspbian Buster 4.19
- Kivy: 1.11.1
- Kivy installation method: https://github.com/kivy/kivy/issues/6413
Description
The same test.py program listed below was used to test all of the Window providers listed above. The second line is changed for each test results.
import os
#os.environ['KIVY_WINDOW'] = 'egl_rpi'
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
When no (default) KIVY_WINDOW defined (test.py above), gets the following results:
[DEBUG ] [Window ] Provider <egl_rpi> ignored by config
[DEBUG ] [Window ] Provider <sdl2> ignored by config
[DEBUG ] [Window ] Provider <x11> ignored by config
[CRITICAL] [Window ] Unable to find any valuable Window provider.
[CRITICAL] [App ] Unable to get a Window, abort.
After changing line 2 by removing the # sign, got the following results:
[DEBUG ] [Window ] Ignored <egl_rpi> (import error)
[DEBUG ] [Window ] Provider <sdl2> ignored by config
[DEBUG ] [Window ] Provider <x11> ignored by config
[CRITICAL] [Window ] Unable to find any valuable Window provider.
egl_rpi - ImportError: cannot import name 'bcm' from 'kivy.lib.vidcore_lite' (/usr/local/lib/python3.7/dist-packages/kivy/lib/vidcore_lite/__init__.py)
File "/usr/local/lib/python3.7/dist-packages/kivy/core/__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/window_egl_rpi.py", line 12, in <module>
from kivy.lib.vidcore_lite import bcm, egl
[CRITICAL] [App ] Unable to get a Window, abort.
After changing line 2 to os.environ['KIVY_WINDOW'] = 'sdl2'
, got the following results:
[DEBUG ] [Window ] Provider <egl_rpi> ignored by config
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored)
[DEBUG ] [Window ] Provider <x11> ignored by config
[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
sdl2 - RuntimeError: b'Could not initialize EGL'
File "/usr/local/lib/python3.7/dist-packages/kivy/core/__init__.py", line 71, in core_select_lib
cls = cls()
File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/window_sdl2.py", line 152, in __init__
super(WindowSDL, self).__init__()
File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/__init__.py", line 981, in __init__
self.create_window()
File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/window_sdl2.py", line 290, in create_window
self.get_gl_backend_name())
File "kivy/core/window/_window_sdl2.pyx", line 224, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
File "kivy/core/window/_window_sdl2.pyx", line 74, in kivy.core.window._window_sdl2._WindowSDL2Storage.die
[CRITICAL] [App ] Unable to get a Window, abort.
After changing line 2 to os.environ['KIVY_WINDOW'] = 'pygame'
, got the following results:
[DEBUG ] [Window ] Provider <egl_rpi> ignored by config
[DEBUG ] [Window ] Provider <sdl2> ignored by config
[DEBUG ] [Window ] Provider <x11> ignored by config
[CRITICAL] [Window ] Unable to find any valuable Window provider.
[CRITICAL] [App ] Unable to get a Window, abort.
After changing line 2 to os.environ['KIVY_WINDOW'] = 'x11'
, got the following results:
[DEBUG ] [Window ] Provider <sdl2> ignored by config
[DEBUG ] [Window ] Ignored <x11> (import error)
[CRITICAL] [Window ] Unable to find any valuable Window provider.
x11 - ModuleNotFoundError: No module named 'kivy.core.window.window_x11'
File "/usr/local/lib/python3.7/dist-packages/kivy/core/__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
[CRITICAL] [App ] Unable to get a Window, abort.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 113 (40 by maintainers)
Here are the instructions on how to install and run a Kivy app at boot on Buster lite:
First install xserver-org, as we need it to show the actual window:
Next I install nodm from source, so it includes the following fix: https://github.com/spanezz/nodm/pull/10:
Now enable graphical login:
Configure nodm and start our app at boot:
Setup a virtual enveriment:
Install Kivy dependencies:
Now it’s time for compiling and installing Kivy. Note that I use my fork with a patch, so it does not use the proprietary Broadcom drivers that are not available on the Raspberry Pi 4 (https://github.com/Lauszus/kivy/commit/9cdcada34a6149b7fd6bd4c57285afc828d69948):
Finally create a small test app:
Now reboot and enjoy 😃
I encountered
failed to add service - already in use?
on buster full, when trying to use theegl_rpi
backend. Fixing it by commenting outdtoverlay=vc4-kms-v3d
in/boot/config.txt
made the error go away, but then kivy didn’t show anything at all.I wonder if it’s the same on buster lite?
@Lauszus
I wasn’t putting the video= parameters on the same line. Wasn’t until you pointed me back to the documentation that I noticed it very explicitly states that all cmdline.txt parameters/configs need to be on one line. Rookie mistake.
Thanks for your help!
Ok, my bad, I forgot to merge https://github.com/kivy/kivy-server/pull/17. Should be fixed now.
For anyone reading this; https://github.com/kivy/kivy/pull/6769 has now been merged, so no changes to Kivy is no longer needed, but you still need to compile SDL2 from source. Instructions can be found in the official docs: https://kivy.org/doc/master/installation/installation-rpi.html.
I never got kivy to work on debian Jessie without a patch either. But if you are okay with using egl, then I have found it useful in the past to patch the initializer in
kivy/core/window/window_egl_rpi.py
, by replacing:I had similar issues with an older version of kivy a couple of months ago, and this did the trick.
If I remember correctly, creating a window using egl fails by default because extra arguments are passed. The exception is caught somewhere, and ignored.
On Debian Jessie, this patch solved all problems for me, but I have not tested this on Buster.
It could still be that the egl option is ignored due to this commit: 333a4cc9c7b4b3168f7427d27f4fdea2a69bc52b.
Anyway, ymmv.
@Gawezi You need to set kivy to use the egl_rpi window, not x11 by setting
KIVY_WINDOW=egl_rpi
. If you did mean to run x11, then make sure to compile kivy with x11 support at installation time (USE_X11=1
).