Kivy 2.0 Installation Difficulties - python-3.x

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.

Related

sdl2 - ImportError: DLL load failed while importing _window_sdl2: The specified module could not be found

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.

Fail Install Kivy on Raspberry Pi 4

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.

How to solve error regarding that it doesnt open window on Kivy?

[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!

Ubuntu mate 18.04 - Kivy app working on desktop but not in cli (Unable to find any valuable Windows provider)

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

No kivy GUI while using vnc to Raspberry

I am developing a kivy app on my RaspberryPi 3 to show a gui and it is working well. When I am connected directly to the pi (HDMI) the gui is showing. When I am using VNC, there is no gui showing, just the main screen/desktop of the pi. I can do anything but showing the kivy gui. After searching a long time I know this is a known issue because kivy is using open gl and vnc is not supporting this. I tried a lot of things like using different vnc-software (RealVNC, x11vnc) or using fbcp to copy the frame buffer (https://www.github.com/tasanakorn/rpi-fbcp) or the things from this post (https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=146749) but without any effect.
My running kivy app shows:
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil,
img_gif (img_ffpyplayer ignored)
[INFO ] [Kivy ] v1.11.0.dev0, git-0471549, 20180720
[INFO ] [Python ] v3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1]
[INFO ] [Factory ] 194 symbols loaded
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: egl_rpi
[INFO ] [GL ] Using the "OpenGL ES 2" graphics system
[INFO ] [GL ] Backend used <gl>
[INFO ] [GL ] OpenGL version <b'OpenGL ES 2.0'>
[INFO ] [GL ] OpenGL vendor <b'Broadcom'>
[INFO ] [GL ] OpenGL renderer <b'VideoCore IV HW'>
[INFO ] [GL ] OpenGL parsed version: 2, 0
[INFO ] [GL ] Shading version <b'OpenGL ES GLSL ES 1.00'>
[INFO ] [GL ] Texture max size <2048>
[INFO ] [GL ] Texture max units <8>
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [KivyMD ] KivyMD version: 0.1.2
[INFO ] [GL ] NPOT texture support is available
Has anyone a solution for this problem? I mean it should be a well known problem because in my opinion it would be very useful to show kivy apps to screens over vnc!!
EDIT:
I solved the problem. Via RealVNC in Experimental Mode (Settings) it is possible to show the kivy app to remote pc. Unfortunately it's very laggy.

Resources