Kivy 应用程序窗口无法在 Pycharm 中启动的问题

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

我一直在尝试在 Pycharm 中运行基本的“Hello World”Kivy 应用程序,但似乎无法让它工作。我阅读了其他有类似问题的人的帖子,但仍然无法解决问题。

我的代码

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


class MyFirstKivyApp(App):
    def build(self):
        # Label with text Hello World is
        # returned as root widget
        return Label(text="Hello World !")

MyFirstKivyApp().run()

错误

我的问题是当应用程序运行时出现此错误

[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.3.3
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.3.1
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.4.5
[INFO   ] [Kivy        ] v2.1.0
[INFO   ] [Kivy        ] Installed at "C:\Users\Jimmy\PycharmProjects\Swipe\venv\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 16:30:00) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\Jimmy\PycharmProjects\Swipe\venv\Scripts\python.exe"
[INFO   ] [Logger      ] Purge log fired. Processing...
[INFO   ] [Logger      ] Purge finished!
[INFO   ] [Factory     ] 189 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_pil (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\Jimmy\PycharmProjects\Swipe\venv\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
 fromlist=[modulename], level=0)
File "<frozen importlib._bootstrap>", line 1086, in __import__
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Jimmy\PycharmProjects\Swipe\venv\lib\site-packages\kivy\core\window\window_sdl2.py", line 28, in <module>
 from kivy.core.window._window_sdl2 import _WindowSDL2Storage

[CRITICAL] [App         ] Unable to get a Window, abort

Iv 尝试删除并重新安装 Kivy 并更新文档中引用的所有文件。我也没有运行导入文件的问题。

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

Pycharm 似乎正在努力运行应用程序虚拟机。大声笑,我让 ChatGPT 查看错误代码,它似乎认为安装有问题,所以我尝试删除并重新安装,但没有成功。下面是我正在使用的所有包的快照。

python pycharm kivy kivy-language
© www.soinside.com 2019 - 2024. All rights reserved.