Kivy 2.0 安装难点
Posted
技术标签:
【中文标题】Kivy 2.0 安装难点【英文标题】:Kivy 2.0 Installation Difficulties 【发布时间】:2021-05-15 19:27:26 【问题描述】:这是我第一次尝试使用 Kivy,但我一直无法运行基本代码。
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
我的错误日志如下:
C:\Users\Owner\AppData\Local\Microsoft\WindowsApps\python3.9.exe C:/Users/Owner/Desktop/python/BeginnerProjects/KivyTest/main.py [INFO] [Logger] 记录登录
C:\Users\Owner\.kivy\logs\kivy_21-02-11_57.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.3.1
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO ] [Kivy ] v2.0.0
[INFO ] [Kivy ] Installed at "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\Owner\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe"
[INFO ] [Factory ] 186 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 while importing _window_sdl2: The specified module could not be found.
File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\kivy\core\__init__.py", line 58, in core_select_lib
mod = __import__(name='2.0.1'.format(
File "C:\Users\Owner\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\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.
Process finished with exit code 1
我尝试重新安装 Kivy,安装所有依赖项,但这些结果没有任何改变。有人知道我该如何解决这些问题吗?
【问题讨论】:
【参考方案1】:看起来像duplicate。
当我没有给主文件main.py
命名时,我遇到了这个错误。
【讨论】:
以上是关于Kivy 2.0 安装难点的主要内容,如果未能解决你的问题,请参考以下文章
Python - Kivy - Python 在安装 kivy 期间停止工作