Spyder not running Kivy script

2019-08-28 18:48发布

问题:

I wrote a script on python 2.7 using kivy. When I run the program in python IDLE it works fine but when I run in in Spyder I get the following error:

runfile('C:/Users/Roelof/Documents/ubuntu_share/plate_count_program/script.py', wdir='C:/Users/Roelof/Documents/ubuntu_share/plate_count_program')
[INFO   ] [Logger      ] Record log in C:\Users\Roelof\.kivy\logs\kivy_18-03-10_12.txt
INFO:kivy:[Logger      ] Record log in C:\Users\Roelof\.kivy\logs\kivy_18-03-10_12.txt
[INFO   ] [Kivy        ] v1.10.0
INFO:kivy:[Kivy        ] v1.10.0
[INFO   ] [Python      ] v2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
INFO:kivy:[Python      ] v2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
INFO:kivy:[Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
INFO:kivy:[Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
INFO:kivy:[Text        ] Provider: sdl2
[INFO   ] [OSC         ] using <thread> for socket
INFO:kivy:[OSC         ] using <thread> for socket
[INFO   ] [Window      ] Provider: sdl2
INFO:kivy:[Window      ] Provider: sdl2
[CRITICAL] [Window      ] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Python27\lib\site-packages\kivy\core\__init__.py", line 67, in core_select_lib
    cls = cls()
  File "C:\Python27\lib\site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
    super(WindowSDL, self).__init__()
  File "C:\Python27\lib\site-packages\kivy\core\window\__init__.py", line 899, in __init__
    self.create_window()
  File "C:\Python27\lib\site-packages\kivy\core\window\window_sdl2.py", line 269, in create_window
    self.fullscreen, resizable, state)
  File "kivy\core\window\_window_sdl2.pyx", line 110, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy\core/window\_window_sdl2.c:2436)
  File "kivy\graphics\cgl.pyx", line 52, in kivy.graphics.cgl.cgl_get_backend_name (kivy\graphics\cgl.c:3044)
  File "kivy\graphics\cgl.pyx", line 60, in kivy.graphics.cgl.cgl_get_backend_name (kivy\graphics\cgl.c:2879)
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)

CRITICAL:kivy:[Window      ] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Python27\lib\site-packages\kivy\core\__init__.py", line 67, in core_select_lib
    cls = cls()
  File "C:\Python27\lib\site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
    super(WindowSDL, self).__init__()
  File "C:\Python27\lib\site-packages\kivy\core\window\__init__.py", line 899, in __init__
    self.create_window()
  File "C:\Python27\lib\site-packages\kivy\core\window\window_sdl2.py", line 269, in create_window
    self.fullscreen, resizable, state)
  File "kivy\core\window\_window_sdl2.pyx", line 110, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy\core/window\_window_sdl2.c:2436)
  File "kivy\graphics\cgl.pyx", line 52, in kivy.graphics.cgl.cgl_get_backend_name (kivy\graphics\cgl.c:3044)
  File "kivy\graphics\cgl.pyx", line 60, in kivy.graphics.cgl.cgl_get_backend_name (kivy\graphics\cgl.c:2879)
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)

[CRITICAL] [App         ] Unable to get a Window, abort.
CRITICAL:kivy:[App         ] Unable to get a Window, abort.
An exception has occurred, use %tb to see the full traceback.

Does anybody have any ideas? I think it might be something with kivy dependencies, but I have them all installed.

回答1:

(Spyder maintainer here) This bug has been reported several times already.

It'll be fixed in our 3.2.8 version, to be released shortly.



回答2:

after running and closing the application, click the X button on the python console. this will open a new python console. you can then run your program without issue.

Or: Ctrl + T