所以,我正在对 Kivy 进行一些修补,但我无法让它工作,我现在只想让屏幕显示出来,但我做不到。不知道是网上看到的代码不好还是有bug还是我安装的时候哪里出错了。 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
您只需使用 pip 在您的 virtualenv 中安装足够的依赖项:
pip install sdl2-lib pillow