I'm trying to run Kivy application on my Raspberry Pi 4 but when i run it, it returns:
[CRITICAL] [Window ] Unable to find any valuable Window provider.
i used https://github.com/kivy/kivy/blob/master/doc/sources/installation/installation-rpi.rst#raspberry-pi-1-4-installation to install environment.
How to fix it?
Versions
Python: 3.7.3
OS: Raspbian GNU/Linux 10 (buster)
Kivy: v2.0.0rc1
Cython: 0.29.10
sdl2, etc. installed
My Code
#! /usr/bin/python3
import os
os.environ['KIVY_VIDEO']='ffpyplayer'
os.environ['KIVY_WINDOW'] = 'sdl2'
import kivy
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()
Result
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_20-01-30_13.txt
[INFO ] [Kivy ] v2.0.0rc1, git-Unknown, 20200130
[INFO ] [Kivy ] Installed at "/home/pi/.local/lib/python3.7/site-packages/kivy/__init__.py"
[INFO ] [Python ] v3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0]
[INFO ] [Python ] Interpreter at "/usr/bin/python3"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2(['text_pango'] ignored)
[INFO ] [Window ] Provider: sdl2
[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''
File "/home/pi/.local/lib/python3.7/site-packages/kivy/core/__init__.py", line 70, in core_select_lib
cls = cls()
File "/home/pi/.local/lib/python3.7/site-packages/kivy/core/window/window_sdl2.py", line 152, in __init__
super(WindowSDL, self).__init__()
File "/home/pi/.local/lib/python3.7/site-packages/kivy/core/window/__init__.py", line 981, in __init__
self.create_window()
File "/home/pi/.local/lib/python3.7/site-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 112, 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.
Thanks :)
I use Python 3.6 and Windows 7. Works on Windows 10 also.
this solution solve the problem in most cases :
Right click on This PC then open Properties .
Go to Advanced system settings .
Click on Environment Variables .
Click on New in User variables for --- .
Put KIVY_GL_BACKEND in Variable name .
Put angle_sdl2 in Variable value .
Restart Python .
Here is a YouTube video showing these steps : https://www.youtube.com/watch?v=ATK9w2AiDeM
If this does not fix it-
Install Visual C++ Redistributable for Visual Studio 2015 and see if that fixes it? The only other thing I can think of is the user thing you mentioned. Windows could be blocking something due to user permissions? Make sure the python you use is installed for the current user.
I would suggest that you completely uninstall kivy (including dependencies), and then make a new virtual environment and then install kivy to it and try again.
Related
This is the first post. I hope it qualifies as a question.
I am trying to auto start 2 python scripts in Raspberry Pi 4 OS.
I created a shell script to run the 2 python scripts.
The shell script works when I manually launch the shell script in the terminal.
When I use crontab to automatically start the shell script,
only 1 of my script started and ran in the background.
The other script which uses Kivy has errors. It seems that kivy needs to be run in a terminal?
Can anyone provide a helping hand please?
The error message is
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_22-08-31_11.txt
[INFO ] [Kivy ] v2.1.0
[INFO ] [Kivy ] Installed at "/home/pi/.local/lib/python3.7/site-packages/kivy/__init__.py"
[INFO ] [Python ] v3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0]
[INFO ] [Python ] Interpreter at "/usr/bin/python3"
[INFO ] [Logger ] Purge log fired. Processing...
[INFO ] [Logger ] Purge finished!
[INFO ] [Factory ] 189 symbols loaded
[INFO ] [ImageLoaderFFPy] Using ffpyplayer 4.3.5
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_ffpyplayer
[INFO ] [Window ] Provider: sdl2
error: XDG_RUNTIME_DIR not set in the environment.
[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 "/home/pi/.local/lib/python3.7/site-packages/kivy/core/__init__.py", line 71, in core_select_lib
cls = cls()
File "/home/pi/.local/lib/python3.7/site-packages/kivy/core/window/window_sdl2.py", line 165, in __init__
super(WindowSDL, self).__init__()
File "/home/pi/.local/lib/python3.7/site-packages/kivy/core/window/__init__.py", line 1071, in __init__
self.create_window()
File "/home/pi/.local/lib/python3.7/site-packages/kivy/core/window/window_sdl2.py", line 309, in create_window
self.get_gl_backend_name())
File "kivy/core/window/_window_sdl2.pyx", line 228, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
File "kivy/core/window/_window_sdl2.pyx", line 76, in kivy.core.window._window_sdl2._WindowSDL2Storage.die
x11 - ModuleNotFoundError: No module named 'kivy.core.window.window_x11'
File "/home/pi/.local/lib/python3.7/site-packages/kivy/core/__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "<frozen importlib._bootstrap>", line 1086, in __import__
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
[INFO ] [KivyMD ] 0.104.2, git-bc7d1f5, 2021-06-06 (installed at "/home/pi/.local/lib/python3.7/site-packages/kivymd/__init__.py")
[INFO ] [Text ] Provider: sdl2(['text_pango'] ignored)
[CRITICAL] [App ] Unable to get a Window, abort.
i am facing this issue while trying to run my kivy ml application in PowerShell or cmd.
i have installed all kivy dependencies but still same error. also i have tried to run it in virtual environment.
(kivy_venv) PS C:\Users\thiru\Downloads\exe file> python3 main.py
[INFO ] [Logger ] Record log in C:\Users\thiru\.kivy\logs\kivy_22-01-24_7.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.3.3
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.1
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO ] [Kivy ] v2.0.0
[INFO ] [Kivy ] Installed at "C:\Users\thiru\AppData\Roaming\Python\Python39\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.9.9 (main, Jan 15 2022, 01:02:02) [MSC v.1929 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "c:\users\thiru\appdata\local\activestate\cache\cc3d5c70\python.exe"
2022-01-24 14:14:10.715828: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2022-01-24 14:14:10.723572: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
[INFO ] [Factory ] 186 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_pil (img_sdl2, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: pil(['text_sdl2'] 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
sdl2 - ImportError: DLL load failed while importing _window_sdl2: The specified module could not be found.
File "C:\Users\thiru\AppData\Roaming\Python\Python39\site-packages\kivy\core\__init__.py", line 58, in core_select_lib
mod = __import__(name='{2}.{0}.{1}'.format(
File "C:\Users\thiru\AppData\Roaming\Python\Python39\site-packages\kivy\core\window\window_sdl2.py", line 27, in <module>
from kivy.core.window._window_sdl2 import _WindowSDL2Storage
[CRITICAL] [App ] Unable to get a Window, abort.
This is my first time trying to use Kivy, and I haven't been able to run a base 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()
And my error log is the following:
C:\Users\Owner\AppData\Local\Microsoft\WindowsApps\python3.9.exe C:/Users/Owner/Desktop/python/BeginnerProjects/KivyTest/main.py
[INFO ] [Logger ] Record log in
C:\Users\Owner\.kivy\logs\kivy_21-02-11_57.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.3.1
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO ] [Kivy ] v2.0.0
[INFO ] [Kivy ] Installed at "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\Owner\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe"
[INFO ] [Factory ] 186 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_pil (img_sdl2, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: pil(['text_sdl2'] 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
sdl2 - ImportError: DLL load failed while importing _window_sdl2: The specified module could not be found.
File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kivy\core\__init__.py", line 58, in core_select_lib
mod = __import__(name='{2}.{0}.{1}'.format(
File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kivy\core\window\window_sdl2.py", line 27, in <module>
from kivy.core.window._window_sdl2 import _WindowSDL2Storage
[CRITICAL] [App ] Unable to get a Window, abort.
Process finished with exit code 1
I've tried reinstalling Kivy, installing all the dependencies, nothing has changed these results. Does anyone have an idea on how I can fix these?
Looks like a duplicate.
I had this error when I didn't give the main file main.py name.
[INFO ] [Logger ] Record log in C:\Users\lenovo\.kivy\logs\kivy_19-12-02_50.txt
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)]
[INFO ] [Python ] Interpreter at "C:\Users\lenovo\PycharmProjects\untitled\venv\Scripts\python.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif (img_sdl2, img_pil, img_ffpyplayer 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
sdl2 - ImportError: DLL load failed: The specified module could not be found.
File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\kivy\core\window\window_sdl2.py", line 27, in <module>
from kivy.core.window._window_sdl2 import _WindowSDL2Storage
[CRITICAL] [App ] Unable to get a Window, abort.
I get this error, anyone can help?
By the way I installed Kivy library trought PyCharm settings!
I've written a kivy app taht works perfectly when launched from ubuntu mate desktop via a terminal window. However, if I boot into cli, the app cannot launch because it is unable to "find any valuable Window provider".
The final goal would be to boot directly into the app when the RPi is started. I plan to do that by booting into cli and then launching my app as a service.
I'm running ubuntu mate 18.04 on a raspberry Pi 3B+ and using kivy to create my program. To make sure that the issue did not come from my script I reproduced the issue using the standard Hello world script from kivy.
Here is the code I use:
import kivy #added this just in case
from kivy.app import App
from kivy.uix.label import Label
class SimpleKivy(App):
def build(self):
return Label(text="Hello World!!!")
if __name__ == "__main__":
SimpleKivy().run()
And here is the error I get:
(cv) droppi#droppi-desktop:~$ python test.py
[INFO ] [Logger ] Record log in /home/droppi/.kivy/logs/kivy_19-07-25_124.txt
[INFO ] [Kivy ] v2.0.0.dev0, git-Unknown, 20190724
[INFO ] [Kivy ] Installed at "/home/droppi/.virtualenvs/cv/lib/python3.6/site-packages/kivy/__init__.py"
[INFO ] [Python ] v3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
[INFO ] [Python ] Interpreter at "/home/droppi/.virtualenvs/cv/bin/python3"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2(['text_pango'] ignored)
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] 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 "/home/droppi/.virtualenvs/cv/lib/python3.6/site-packages/kivy/core/__init__.py", line 62, in core_select_lib
fromlist=[modulename], level=0)
File "/home/droppi/.virtualenvs/cv/lib/python3.6/site-packages/kivy/core/window/window_egl_rpi.py", line 12, in <module>
from kivy.lib.vidcore_lite import bcm, egl
sdl2 - RuntimeError: b'No available video device'
File "/home/droppi/.virtualenvs/cv/lib/python3.6/site-packages/kivy/core/__init__.py", line 70, in core_select_lib
cls = cls()
File "/home/droppi/.virtualenvs/cv/lib/python3.6/site-packages/kivy/core/window/window_sdl2.py", line 152, in __init__
super(WindowSDL, self).__init__()
File "/home/droppi/.virtualenvs/cv/lib/python3.6/site-packages/kivy/core/window/__init__.py", line 983, in __init__
self.create_window()
File "/home/droppi/.virtualenvs/cv/lib/python3.6/site-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 110, 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
x11 - ModuleNotFoundError: No module named 'kivy.core.window.window_x11'
File "/home/droppi/.virtualenvs/cv/lib/python3.6/site-packages/kivy/core/__init__.py", line 62, in core_select_lib
fromlist=[modulename], level=0)
[CRITICAL] [App ] Unable to get a Window, abort.
I assume the issue is linked to the fact that there is no x session active in cli mode but I did not find a way to get only a window provider for my app without going to the desktop first with something like startX.
I guess my question is: How do I make the kivy app launchable from a cli boot?
EDIT:
I had kivy app working before on Ubuntu Mate 16.04 also on raspberry pi (3B, not b+) in cli mode. Both manually launched or from a service but I cannot seem to make it work with the new Ubuntu