无法使Kivy代码正常工作

时间:2015-01-14 04:09:07

标签: python kivy

我正在尝试使用Kivy运行一个简单的hello world程序。我的Mac上安装了正确的版本(1.8),但是收到错误消息并且窗口没有打开。

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

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

TestApp().run()

$ python hello_world.py 
[INFO              ] Kivy v1.8.0
[INFO              ] [Logger      ] Record log in /Users/d/.kivy/logs/kivy_15-01-13_4.txt
[INFO              ] [Factory     ] 157 symbols loaded
[DEBUG             ] [Cache       ] register <kv.lang> with limit=None, timeout=Nones
[DEBUG             ] [Cache       ] register <kv.image> with limit=None, timeout=60s
[DEBUG             ] [Cache       ] register <kv.atlas> with limit=None, timeout=Nones
[INFO              ] [Image       ] Providers: img_imageio, img_tex, img_dds, img_pil,     img_gif (img_pygame ignored)
[DEBUG             ] [Cache       ] register <kv.texture> with limit=1000, timeout=60s
[DEBUG             ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600s
[DEBUG             ] [Text        ] Ignored <pygame> (import error)
[DEBUG             ] [Text        ] Ignored <sdlttf> (import error)
[INFO              ] [Text        ] Provider: pil(['text_pygame', 'text_sdlttf'] ignored)
[DEBUG             ] [App         ] Loading kv <./test.kv>
[DEBUG             ] [App         ] kv <./test.kv> not found
[DEBUG             ] [Window      ] Ignored <egl_rpi> (import error)
[DEBUG             ] [Window      ] Ignored <pygame> (import error)
[WARNING           ] [WinPygame   ] SDL wrapper failed to import!
[DEBUG             ] [Window      ] Ignored <sdl> (import error)
[DEBUG             ] [Window      ] Ignored <x11> (import error)
[CRITICAL          ] [Window      ] Unable to find any valuable Window provider at all!
[CRITICAL          ] [App         ] Unable to get a Window, abort.
Exception SystemExit: 1 in 'kivy.properties.dpi2px' ignored
[CRITICAL          ] [App         ] Unable to get a Window, abort.

1 个答案:

答案 0 :(得分:0)

根据行

[DEBUG             ] [Text        ] Ignored <pygame> (import error)
[DEBUG             ] [Text        ] Ignored <sdlttf> (import error)
正如Mark Ransom所说,你对Kivy的依赖可能是不正确的安装或过时的。尝试更新Kivy的依赖项。 This thread在Github Kivy论坛上已经详细介绍了这个问题,虽然它是在Ubuntu而不是Mac OSX上,并且有几个用户报告说更新Kivy依赖关系可以解决这个问题。