question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Buster RPi4B unable to find valuable Window provider from Desktop-less console

See original GitHub issue

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

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:113 (40 by maintainers)

github_iconTop GitHub Comments

4reactions
Lauszuscommented, Oct 21, 2019

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:

sudo apt-get -y install xserver-xorg

Next I install nodm from source, so it includes the following fix: https://github.com/spanezz/nodm/pull/10:

sudo apt-get -y install libpam0g-dev help2man libx11-dev debhelper
git clone https://github.com/slashblog/nodm.git
pushd nodm
    git checkout d48a8f6266d3f464138e0e95b65896917c35c89f
    source /etc/os-release  # Will set the 'VERSION' variable
    if [ "$(echo $VERSION | sed -En 's/[0-9]+ \(([a-z]+)\)/\1/p')" == "buster" ]; then
        wget http://deb.debian.org/debian/pool/main/n/nodm/nodm_0.13-5.debian.tar.xz
    else
        wget http://deb.debian.org/debian/pool/main/n/nodm/nodm_0.13-1.3.debian.tar.xz
    fi
    tar xf nodm_0.13-*.debian.tar.xz
    sudo dpkg-buildpackage -us -uc -b
popd
sudo dpkg -i nodm_0.13-*_armhf.deb
sudo rm -rf nodm*

Now enable graphical login:

sudo systemctl set-default graphical.target

Configure nodm and start our app at boot:

# Has the same effect as calling 'sudo dpkg-reconfigure nodm'
sudo sh -c 'echo "NODM_ENABLED=true" > /etc/default/nodm'
sudo sh -c 'echo "NODM_USER=$SUDO_USER" >> /etc/default/nodm' # Note that the variable SUDO_USER is used
sudo sh -c 'echo "NODM_FIRST_VT='\''7'\''" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_XSESSION=/etc/X11/Xsession" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_X_OPTIONS='\''-nolisten tcp'\''" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_MIN_SESSION_TIME=60" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_X_TIMEOUT=300" >> /etc/default/nodm'

# Start the app using nodm
echo '#!/bin/bash' > ~/.xsession
echo 'export DISPLAY=:0.0' >> ~/.xsession
echo "~/venv-kivy/bin/python3 ~/app.py" >> ~/.xsession

Setup a virtual enveriment:

sudo apt-get -y install python3-pip python3-venv
sudo pip3 install -U pip
python3 -m venv venv-kivy
source ~/venv-kivy/bin/activate

Install Kivy dependencies:

sudo apt-get -y install python3-dev libmtdev1 libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
sudo apt-get -y install pkg-config libgl1-mesa-dev libgles2-mesa-dev libgstreamer1.0-dev gstreamer1.0-plugins-{bad,base,good,ugly} gstreamer1.0-{omx,alsa} libmtdev-dev
pip3 install -U pygments docutils Cython==0.29.10 wheel

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):

export VIDEOCOREMESA=1; pip3 install git+https://github.com/Lauszus/kivy.git@rpi4_auto#egg=kivy

Finally create a small test app:

cat <<EOF > ~/app.py
from kivy.app import App
from kivy.uix.button import Button


class TestApp(App):

    def build(self):
        return Button(text='hello world')


if __name__ == '__main__':
    TestApp().run()
EOF

Now reboot and enjoy 😃

2reactions
mathamcommented, Aug 19, 2019

I encountered failed to add service - already in use? on buster full, when trying to use the egl_rpi backend. Fixing it by commenting out dtoverlay=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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kivy not working (Error: Unable to find any valuable Window ...
To install these dependencies, open up a terminal (can be a console, Pycharm Terminal window, etc.), run the first command and then the ......
Read more >
Bountysource
Buster RPi4B unable to find valuable Window provider from Desktop-less console.
Read more >
Unable to find any valuable Window provider for Raspberry Pi ...
I have a Kivy UI application developed that I would like to run on my raspberry pi 3b+ running raspbian lite (console). Since...
Read more >
Open source UI framework written in Python, running on ...
Buster RPi4B unable to find valuable Window provider from Desktop-less console ... Python: 3.7.3; OS: Raspbian Buster 4.19; Kivy: 1.11.1 ...
Read more >
Kivy: "Unable to find any valuable Window provider" [SOLVED]
I have installed Kivy. I followed the instructions for Python3 "Using software packages (PPA etc.)" here:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found