无法使用Kivy获取窗口或文本提供程序

问题描述 投票:0回答:1

我对编码和Kivy业务非常陌生。我为自己的无知表示歉意。首先,我认为我的PATH出了点问题。有时,在我使用pip安装模块后,这些模块将永远无法被识别,因此可能是问题所在。最近,我已经从Sublime Text过渡到Visual Studio2019。我已经尝试了Internet上提供的所有教程。我认为问题是我,我不明白自己在做什么。附件是我尝试过的所有建议:

我现在已经以所有这些不同的配置卸载和安装了Kivy 4或5次。如果我发送任何依赖项以进行下载,我保证它会告诉我它已经满足了。

这里是程序:

import kivy

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

class FirstKivy(App):
    def build(self):
        return Label(text="Hello World")

if __name__ == '__main__':
    FirstKivy().run()
[INFO   ] [Logger      ] Record log in C:\Users\wlade\.kivy\logs\kivy_20-05-14_38.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        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "C:\Users\wlade\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 11:52:54) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\wlade\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\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: The specified module could not be found.
  File "C:\Users\wlade\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\wlade\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\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.

这里是Visual Studio给我的错误


  Message=1
  Source=C:\Users\wlade\source\repos\PythonApplication1\PythonApplication1\PythonApplication1.py
  StackTrace:
  File "C:\Users\wlade\source\repos\PythonApplication1\PythonApplication1\PythonApplication1.py", line 8, in build
    return Label(text="Hello World")
  File "C:\Users\wlade\source\repos\PythonApplication1\PythonApplication1\PythonApplication1.py", line 11, in <module>
    FirstKivy().run()

感谢您的耐心等待:)

python python-3.x kivy kivy-language
1个回答
0
投票

我的项目中有相同的问题,但我解决了。我在项目中安装了[kivy-deps.sdl2][kivy-deps.glew]软件包它开始运行。我将PyCharm用于开发工具,并安装了以下过程:

  1. 转到[Settings]

  2. 选择[Project][Project Iterpreter]

  3. 使用+ kivy安装软件包添加要运行的软件包:[Kivy],[kivy-deps.sdl2][kivy-deps.glew]

© www.soinside.com 2019 - 2024. All rights reserved.