问题
I am starting with kivy. here is the sample code I am running.
import kivy
from kivy.app import App
from kivy.uix.button import Label
kivy.require('1.9.0')
class HelloApp(App):
def build(self):
return Label(text='Hello World!')
if __name__ == "__main__":
HelloApp().run()
and here is the traceback I am getting:
[INFO ] [Logger ] Record log in C:\Users\monac\.kivy\logs\kivy_16-11-23_9.txt
[INFO ] [Kivy ] v1.9.1
[INFO ] [Python ] v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)]
[INFO ] [Factory ] 179 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [OSC ] using <thread> for socket
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] OpenGL version <b'4.5.0 NVIDIA 373.06'>
[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] [GL ] OpenGL renderer <b'GeForce GTX 960M/PCIe/SSE2'>
[INFO ] [GL ] OpenGL parsed version: 4, 5
[INFO ] [GL ] Shading version <b'4.50 NVIDIA'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[WARNING ] [Image ] Unable to load image <C:\Python34\lib\site-packages\kivy\data\glsl\default.png>
[CRITICAL ] [Window ] Unable to find any valuable Window provider at all!
sdl2 - Exception: SDL2: Unable to load image
File "C:\Python34\lib\site-packages\kivy\core\__init__.py", line 67, in core_select_lib
cls = cls()
File "C:\Python34\lib\site-packages\kivy\core\window\window_sdl2.py", line 138, in __init__
super(WindowSDL, self).__init__()
File "C:\Python34\lib\site-packages\kivy\core\window\__init__.py", line 722, in __init__
self.create_window()
File "C:\Python34\lib\site-packages\kivy\core\window\window_sdl2.py", line 255, in create_window
super(WindowSDL, self).create_window()
File "C:\Python34\lib\site-packages\kivy\core\window\__init__.py", line 897, in create_window
self.render_context = RenderContext()
File "kivy\graphics\instructions.pyx", line 756, in kivy.graphics.instructions.RenderContext.__init__ (kivy\graphics\instructions.c:10729)
File "C:\Python34\lib\site-packages\kivy\core\image\__init__.py", line 512, in __init__
self.filename = arg
File "C:\Python34\lib\site-packages\kivy\core\image\__init__.py", line 700, in _set_filename
mipmap=self._mipmap, nocache=self._nocache)
File "C:\Python34\lib\site-packages\kivy\core\image\__init__.py", line 430, in load
im = loader(filename, **kwargs)
File "C:\Python34\lib\site-packages\kivy\core\image\__init__.py", line 198, in __init__
self._data = self.load(filename)
File "C:\Python34\lib\site-packages\kivy\core\image\img_sdl2.py", line 42, in load
raise Exception('SDL2: Unable to load image')
[CRITICAL ] [App ] Unable to get a Window, abort.
Exception ignored in: 'kivy.properties.dpi2px'
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\kivy\utils.py", line 513, in __get__
retval = self.func(inst)
File "C:\Python34\lib\site-packages\kivy\metrics.py", line 175, in dpi
EventLoop.ensure_window()
File "C:\Python34\lib\site-packages\kivy\base.py", line 126, in ensure_window
sys.exit(1)
SystemExit: 1
[CRITICAL ] [App ] Unable to get a Window, abort.
I am running on windows 10 64bits. I have installed all the dependencies except gstreamer
which I won't need at the moment.
I am also not sure why I am getting this error:
[WARNING ] [Image ] Unable to load image <C:\Python34\lib\site-packages\kivy\data\glsl\default.png>
The file exists and I am running my code as admin to avoid access rights problems.
Thank you.
回答1:
You have to install the dependencies for Kivy.
Follow the instructions here
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
will do what you needed.
回答2:
I hit this same error after installing kivy and its dependencies prior to creating my virtualenv with --system-site-packages
. To resolve it, I had to leave my virtualenv, uninstall all packages kivy, enter my virtualenv, and reinstall.
回答3:
you have to install all dependency check this url in detail https://kivy.org/docs/installation/installation-windows.html#kivy-dependencies i followed all step by step don't forget install kivy.deps.angle, kivy.deps.glew, kivy.deps.gstreamer, kivy.deps.sdl2
回答4:
In the display settings of the virtual software (aka vmbox, vmware) disable the 3D acceleration and the 2D video acceleration . I think this will work for you , it works for me after lots of tries.
回答5:
Some might have had the same issue when using a dist generated by pyinstaller.
Kivy doc reminds the developer to add those dependencies. https://kivy.org/doc/stable/guide/packaging-windows.html#pyinstaller-default-hook
but i had to add angle to make it work in my context.
from kivy_deps import sdl2, glew, angle
coll = COLLECT(exe, Tree('examples-path\\demo\\touchtracer\\'),
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins+ angle.dep_bins)],
strip=False,
upx=True,
name='touchtracer')
回答6:
I use Ubuntu 18.04, I installed pygame in the virtual environment I was working in. It seemed to fix the error.
来源:https://stackoverflow.com/questions/40769386/kivy-windows-unable-to-find-any-valuable-window-provider-at-all