Pycharm with Kivy Error [CRITICAL] [App ] Unable t

2019-07-28 18:50发布

问题:

I am trying to get one of the example Kivy codes running on my machine. I am using the Pycharm community edition 2017.1 with anaconda python 2.7 and Kivy 1.9 installed. I have used the project settings to install the Kivy module and the Pygame module into the project. I then run the code:

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()

However I get the error:

[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.

I suspect i do not have sdl2? Not sure what it s though... Any suggestions?

回答1:

This will definitely gonna do the trick:

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


回答2:

when you using Window 7 32 bit system and see this error

try this:>> 1-> open cmd 2->python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew



回答3:

kivy uses pygame to create/ build a window so probably it's missing. try:

pip(3) install pygame


回答4:

Use this if you are using python3.x.x versions in Windows:

  • pip3 install pygame