【问题标题】:Kivy Python 3.7 app doesn't work - ImportErrorKivy Python 3.7 应用程序不起作用 - ImportError
【发布时间】:2020-07-17 11:36:57
【问题描述】:

我正在尝试使用带有 Kivy 模块的 python 3.7 创建我的第一个移动应用程序。 当我运行脚本时出现错误。

脚本:

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


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


if __name__ == "__main__":
    Host().run()

错误:

[INFO   ] [Logger      ] Record log in C:\Users\user\.kivy\logs\kivy_20-07-17_57.txt
[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\user\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\user\AppData\Local\Programs\Python\Python37\pythonw.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\user\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\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.

【问题讨论】:

    标签: python python-3.x kivy


    【解决方案1】:

    我设法解决了这个问题。 我使用以下命令下载了 kivy 的依赖项:

    python -m pip install docutils pygments pypiwin32 kivy_deps.sdl2==0.1.* kivy_deps.glew==0.1.*
    python -m pip install kivy_deps.gstreamer==0.1.*
    python -m pip install kivy_deps.angle==0.1.*
    

    现在它开始工作了。

    【讨论】:

      猜你喜欢
      • 2015-09-03
      • 2019-09-19
      • 1970-01-01
      • 2015-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多