首页 > 解决方案 > Kivi 未执行,因为未找到 PIL

问题描述

所以,我对 Kivy 进行了一些修改,但我无法让它工作,我现在只想不能在屏幕上显示,但我做不到。我不知道我在网上看到的代码是否有问题,或者是否有错误,或者我在安装时做错了什么。PD:我正在使用 Windows 和 Pycharm。

我尝试多次卸载并重新安装 Kivy 和 PIL 和 Pillow,在 app.py 中写入 import PIL 和 Pillow。

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


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


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

这是它给我的错误:

[INFO   ] [Logger      ] Record log in C:\Users\j\.kivy\logs\kivy_19-11-07_20.txt

[INFO   ] [Kivy        ] v1.11.1

[INFO   ] [Kivy        ] Installed at "C:\Users\j\Documents\PycharmProjects\Python_Test\venv\lib\site-packages\kivy\__init__.py"

[INFO   ] [Python      ] v3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)]

[INFO   ] [Python      ] Interpreter at "C:\Users\j\Documents\PycharmProjects\Python_Test\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: The specified module could not be found.
  File "C:\Users\j\Documents\PycharmProjects\Python_Test\venv\lib\site-packages\kivy\core\__init__.py", line 62, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\j\Documents\PycharmProjects\Python_Test\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\j\Documents\PycharmProjects\Python_Test\venv\lib\site-packages\kivy\core\__init__.py", line 62, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\j\Documents\PycharmProjects\Python_Test\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

标签: pythonpython-3.xkivypython-imaging-librarykivy-language

解决方案


推荐阅读