import kivy
kivy.require('1.10.0')
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()
错误:
[INFO ] [Logger ] Record log in C:\Users\Ashu Sharma\.kivy\logs\kivy_17-10-03_0.txt
[INFO ] [Kivy ] v1.10.0
[INFO ] [Python ] v3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [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\Ashu Sharma\AppData\Local\Programs\Python\Python35-32\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\Ashu Sharma\AppData\Local\Programs\Python\Python35-32\lib\site-packages\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\Ashu Sharma\AppData\Local\Programs\Python\Python35-32\lib\site-packages\kivy\utils.py", line 496, in __get__
retval = self.func(inst)
File "C:\Users\Ashu Sharma\AppData\Local\Programs\Python\Python35-32\lib\site-packages\kivy\metrics.py", line 174, in dpi
EventLoop.ensure_window()
File "C:\Users\Ashu Sharma\AppData\Local\Programs\Python\Python35-32\lib\site-packages\kivy\base.py", line 127, in ensure_window
sys.exit(1)
SystemExit: 1
[CRITICAL] [App ] Unable to get a Window, abort.
答案 0 :(得分:0)
您缺少 PIL 相关性,请通过
安装py -3.5 -m pip install pillow
Pillow 是 python3 PIL ......
答案 1 :(得分:0)
[CRITICAL] [Window ] Unable to find any valuable Window provider. sdl2 - ImportError: DLL load failed: The specified module could not be found.
来自官方Kivy网站:https://kivy.org/docs/installation/installation-windows.html
安装依赖项(如果不需要,请跳过gstreamer(~120MB),请参阅 Kivy的依赖关系):
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
python -m pip install kivy.deps.gstreamer
尤其是 kivy.deps.sdl2