在新的Windows 10上使用kivy运行python文件时出现以下错误:
C:\Users\Me\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/Me/Desktop/PycharmProjects/music_game_kivy/music_game_kivy.py
[INFO ] [Logger ] Record log in C:\Users\Me\.kivy\logs\kivy_17-12-26_10.txt
[INFO ] [Kivy ] v1.10.0
[INFO ] [Python ] v3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
[INFO ] [Factory ] 194 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.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
File "C:\Users\Me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\Me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\text\text_sdl2.py", line 12, in <module>
from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,
pil - ModuleNotFoundError: No module named 'PIL'
File "C:\Users\Me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\Me\AppData\Local\Programs\Python\Python36-32\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
完全相同的python文件在我的旧Mac上正常运行。我没有发布整个代码,因为它差不多有1500行...如果它有用,这里是我从代码顶部导入的:
from kivy.app import App
from kivy.clock import Clock
from kivy.graphics import Color, Rectangle
from kivy.uix.button import Button
from kivy.uix.image import Image
from kivy.uix.label import Label
from kivy.uix.widget import Widget
from random import randrange
非常感谢任何帮助!
这是安装Pillow后的新错误消息:
C:\Users\Me\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/Me/Desktop/PycharmProjects/music_game_kivy/music_game_kivy.py
[INFO ] [Logger ] Record log in C:\Users\Me\.kivy\logs\kivy_17-12-26_11.txt
[INFO ] [Kivy ] v1.10.0
[INFO ] [Python ] v3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
[INFO ] [Factory ] 194 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_pil, img_gif (img_sdl2, img_ffpyplayer ignored)
[INFO ] [Audio ] Providers: (audio_ffpyplayer, audio_sdl2 ignored)
[CRITICAL] [Window ] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
File "C:\Users\Me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\Me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\window\window_sdl2.py", line 26, in <module>
from kivy.core.window._window_sdl2 import _WindowSDL2Storage
[INFO ] [Text ] Provider: pil(['text_sdl2'] ignored)
[CRITICAL] [App ] Unable to get a Window, abort.
Process finished with exit code 1
答案 0 :(得分:0)
对于Windows,请从命令提示符处尝试以下命令:
pip install Pillow
要么
python -m pip install Pillow
Pillow是PIL的一个分支,即Python成像库,不再维护。但是,为了保持向后兼容性,使用旧模块名称。
对于sdl2尝试以下(windows):
python -m pip install kivy.deps.sdl2
python -m pip install kivy.deps.glew
或尝试:
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew