带有Kivy错误的Pycharm [CRITICAL] [App]无法获取窗口,中止

时间:2017-05-08 10:49:05

标签: python pycharm kivy

我想在我的机器上运行一个示例Kivy代码。我使用的是Pycharm社区版2017.1,安装了anaconda python 2.7和Kivy 1.9。我已经使用项目设置将Kivy模块和Pygame模块安装到项目中。然后我运行代码:

from kivy.app import App
from kivy.uix.widget import Widget


class PongGame(Widget):
     pass


 class PongApp(App):
     def build(self):
         return PongGame()


 if __name__ == '__main__':
     PongApp().run()

然而我收到错误:

[INFO   ] [Logger      ] Record log in C:\Users\Rastko\.kivy\logs\kivy_17-
05-08_41.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 
20:42:59) [MSC v.1500 32 bit (Intel)]
[INFO   ] [Factory     ] 194 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.
sdl2 - ImportError: DLL load failed: The specified module could not be 
found.
  File "C:\Users\Rastko\AppData\Roaming\Python\Python27\site-
packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\Rastko\AppData\Roaming\Python\Python27\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.

我怀疑我没有sdl2?不确定它是什么...有什么建议吗?

4 个答案:

答案 0 :(得分:1)

这肯定会成功:

pip install git+https://github.com/kivy/kivy.git@master

答案 1 :(得分:1)

使用Window 7 32位系统时 并看到此错误

尝试:>> 1->打开cmd 2-> python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew

答案 2 :(得分:0)

kivy使用pygame来创建/构建一个窗口,所以可能它已经丢失了。尝试:

pip(3) install pygame

答案 3 :(得分:0)

如果您在Windows中使用python3.x.x版本,请使用此选项:

  • pip3 install pygame