【问题标题】:simple kivy app gives me an error (pycharm) [duplicate]简单的 kivy 应用程序给了我一个错误(pycharm)[重复]
【发布时间】:2019-11-19 20:26:58
【问题描述】:

所以我想从 kivy 开始。所以我首先尝试运行一个简单的代码,但它确实给了我一个我无法修复的错误?

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


class MyApp(App):
    def build(self):
        return Label(text="Test")


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

如果我运行这段代码,控制台会给我这个输出:


[INFO   ] [Logger      ] Record log in C:\Users\Gamer\.kivy\logs\kivy_19-11-19_85.txt
[INFO   ] [Kivy        ] v1.11.0
[INFO   ] [Kivy        ] Installed at "C:\Users\Gamer\PycharmProjects\TimeDrillerv1\venv\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)]
[INFO   ] [Python      ] Interpreter at "C:\Users\Gamer\PycharmProjects\TimeDrillerv1\venv\Scripts\python.exe"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif (img_sdl2, img_pil, img_ffpyplayer ignored)
[CRITICAL] [Text        ] Unable to find any valuable Text 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: Das angegebene Modul wurde nicht gefunden.
  File "C:\Users\Gamer\PycharmProjects\TimeDrillerv1\venv\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\Gamer\PycharmProjects\TimeDrillerv1\venv\lib\site-packages\kivy\core\text\text_sdl2.py", line 13, in <module>
    from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,

pil - ModuleNotFoundError: No module named 'PIL'
  File "C:\Users\Gamer\PycharmProjects\TimeDrillerv1\venv\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\Gamer\PycharmProjects\TimeDrillerv1\venv\lib\site-packages\kivy\core\text\text_pil.py", line 7, in <module>
    from PIL import Image, ImageFont, ImageDraw

[CRITICAL] [App         ] Unable to get a Text provider, abort.

Process finished with exit code 1

怎么了?

【问题讨论】:

  • 您的 kivy 未正确安装/编译。你是怎么安装的?
  • 一旦我按照 kivy 网站上的步骤将它安装到我的 Windows 上。
  • 其次我使用项目解释器在pycharm中安装了kivy
  • 缺少 PIL 模块 pip install pillow
  • @abhilb 好的,谢谢。工作,但现在我得到 [CRITICAL] [App] Unable to get a Window, abort.

标签: python python-3.x pycharm kivy


【解决方案1】:

试试

pip install --upgrade pip wheel setuptools
pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
pip install kivy.deps.gstreamer
pip install kivy.deps.angle

https://github.com/kivy/kivy/issues/5859

启用调试级别日志记录以检查失败原因的详细报告。

from kivy.config import Config
Config.set('kivy', 'log_level', 'debug')
Config.write()

【讨论】:

  • 没有为我工作。我使用 pycharm,看起来它根本没有改变任何想法;p
  • 是否仍然显示无法获取窗口?
  • 我找到了解决窗口问题的方法。这是因为pycharm。它使用 python37 - 32 目录来获取已安装的模块,而 pip 将everythink 安装到 python37 - 65(位)中,所以我更改了目录,现在它可以工作了:)
  • 这里有答案的帖子:stackoverflow.com/questions/49466785/…
猜你喜欢
  • 2017-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多