猕猴桃找不到有价值的窗口

时间:2020-04-26 23:36:43

标签: python windows kivy

我正在尝试遵循kivy教程,而测试代码是这样的:

import kivy
from kivy.app import App
from kivy.uix.label import Label

class myApp(App):

    def build(self):
        return Label(text="Tech With Tim")


if __name__ == "__main__":

    myApp().run()

但是,我在控制台中得到了这个

[INFO   ] [Logger      ] Record log in C:\Users\ultra\.kivy\logs\kivy_20-04-26_1.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.2.0
[INFO   ] [Kivy        ] v2.0.0rc1, git-ae0fa0c, 20191229
[INFO   ] [Kivy        ] Installed at "C:\Users\ultra\AppData\Roaming\Python\Python38\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)]
[INFO   ] [Python      ] Interpreter at "C:\Program Files (x86)\Python38-32\python.exe"
[INFO   ] [Factory     ] 184 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. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - ImportError: DLL load failed while importing _window_sdl2: The specified module could not be found.
  File "C:\Users\ultra\AppData\Roaming\Python\Python38\site-packages\kivy\core\__init__.py", line 58, in core_select_lib
    mod = __import__(name='{2}.{0}.{1}'.format(
  File "C:\Users\ultra\AppData\Roaming\Python\Python38\site-packages\kivy\core\window\window_sdl2.py", line 27, in <module>
    from kivy.core.window._window_sdl2 import _WindowSDL2Storage

[CRITICAL] [App         ] Unable to get a Window, abort.
1
Stack trace:
 >  File "C:\Users\ultra\Desktop\Python Scripts\The App\Kivy Tutorial\kivyAppTutorial.py\kivyAppTutorial.py\kivyAppTutorial.py.py", line 8, in build
 >    return Label(text="Tech With Tim")
 >  File "C:\Users\ultra\Desktop\Python Scripts\The App\Kivy Tutorial\kivyAppTutorial.py\kivyAppTutorial.py\kivyAppTutorial.py.py", line 13, in <module>
 >    myApp().run()
Loaded '__main__'
Loaded 'kivy.app'
Loaded 'runpy'
The program 'python.exe' has exited with code -1 (0xffffffff).

我不知道该如何解决。一些类似的问题说这是一个安装问题,但是我完全按照安装进行操作,而且解决方案也不起作用。任何帮助将非常感激。

我正在Windows 10上运行python 3.8.1。在Visual Studio中以及通过cmd运行.py文件均失败。

1 个答案:

答案 0 :(得分:1)

运行以下pip命令,然后尝试再次执行该程序!

python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew --extra-index-url https://kivy.org/downloads/packages/simple/

这可能会解决您的问题!