我在pycharm中尝试使用Kivy(1.10.0),当用它来测试安装时:
from kivy.app import App
from kivy.uix.button import Button
class TutorialApp(App):
def build(self):
return Button(text='Hello Kivy')
if __name__ == '__main__':
TutorialApp().run()
这也尝试使用'Label'代替'Button'
我在pycharm中运行时都得到了这个:
[INFO ] [Logger ] Record log in C:\Users\Denise\.kivy\logs\kivy_17-08-12_56.txt
[INFO ] [Kivy ] v1.10.0
[INFO ] [Python ] v3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [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\Denise\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\Denise\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\Denise\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\Denise\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.
键入以下内容时,python 3.6.1 shell中发生了同样的错误:
from kivy.uix.button import Button
或
from kivy.uix.button import Lable
请帮助,我如何让Kivy跑步?
答案 0 :(得分:4)
根据源代码
if 'KIVY_DOC' not in os.environ:
if not Label:
from kivy.logger import Logger
import sys
Logger.critical('App: Unable to get a Text provider, abort.')
sys.exit(1)
确保已根据installation guide.
安装了所有依赖项答案 1 :(得分:3)
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
pip install –-upgrade kivy
这将解决所有问题
答案 2 :(得分:1)
在Project Interpreter的PyCharmm中,添加所有以以下内容开头的包:
kivy-deps。
排除标题中带有“ dev”的那些
答案 3 :(得分:0)
我遇到了这个问题,然后我就这样做了......(这适用于使用pycharm并安装所有软件包但仍无法正常工作的人)
在settings-&gt; Project Interpreter - &gt; Green Plus Icon中安装包
然后搜索&#34; kivy.deps.sdl2&#34;,然后安装。
我希望这会有所帮助。
答案 4 :(得分:0)
引用:https://github.com/kivy/kivy/issues/5677#issuecomment-389980378-permalink
詹姆斯的回答对我很有帮助。
在Windows上,可以将%AppData%\Python\share\glew\bin;%AppData%\Python\share\sdl2\bin;
放在PATH之前来“解决”: