我不能让Kivy“Hello World”的例子起作用

时间:2018-03-25 18:25:18

标签: python python-3.x user-interface pip kivy

对于某些共鸣,我似乎无法让Kivy "Hello world"起作用。

我花了几个小时在线研究这个问题并查看了我在Stack Overflow上可以找到的所有相关问题。

我删除并重新安装了kivy和python。

我已经安装了所有kivys依赖项,还有枕头。

如果它有所作为我正在使用python 3。

这是我的代码。

from kivy.app import App
from kivy.uix.button import Button

class TestApp(App):
    def build(self):
        return Button(text='Hello World')

TestApp().run()

这是我得到的回应。

[INFO   ] [Logger      ] Record log in C:\Users\Luc\.kivy\logs\kivy_18-03-25_6.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_pil, img_gif (img_sdl2, img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: pil(['text_sdl2'] ignored)
[CRITICAL] [Window      ] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Users\Luc\AppData\Local\Programs\Python\Python36-32\Lib\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\Luc\AppData\Local\Programs\Python\Python36-32\Lib\kivy\core\window\window_sdl2.py", line 26, in <module>
    from kivy.core.window._window_sdl2 import _WindowSDL2Storage

[CRITICAL] [App         ] Unable to get a Window, abort.
 Exception ignored in: 'kivy.properties.dpi2px'
 Traceback (most recent call last):
   File "C:\Users\Luc\AppData\Local\Programs\Python\Python36-32\Lib\kivy\utils.py", line 496, in __get__
     retval = self.func(inst)
   File "C:\Users\Luc\AppData\Local\Programs\Python\Python36-32\Lib\kivy\metrics.py", line 174, in dpi
     EventLoop.ensure_window()
   File "C:\Users\Luc\AppData\Local\Programs\Python\Python36-32\Lib\kivy\base.py", line 127, in ensure_window
     sys.exit(1)
 SystemExit: 1
[CRITICAL] [App         ] Unable to get a Window, abort.

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

Take a look at this answer. It appears you need kivy.deps.sdl2.