已有184人关注
为什么第一个程序我这里就出错
发表在Python图书答疑 2021-07-13 《Python+Kivy(App 开发)从入门到实践》第1章 Hello Kivy 5页-6页
是否精华
版块置顶:
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout

class IndexPage(BoxLayout):
    def __init__(self,**kwargs):
        super().__init__(**kwargs)
        #添加一个按钮
        self.join = Button(text='Hello World')
        #将按钮添加到页面控件中
        self.add_widget(self.join)

class TestApp(App):
    def build(self):
        return IndexPage()


if __name__ == '__main__':
    TestApp().run()

[INFO   ] [Logger      ] Record log in C:\Users\Young\.kivy\logs\kivy_21-07-13_89.txt

[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.1.17

[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.3.0

[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.3.0

[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.3.1

[INFO   ] [Kivy        ] v2.0.0

[INFO   ] [Kivy        ] Installed at "E:\KV\kv-demo-env\lib\site-packages\kivy\__init__.py"

[INFO   ] [Python      ] v3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]

[INFO   ] [Python      ] Interpreter at "E:\KV\kv-demo-env\Scripts\python.exe"

[INFO   ] [Factory     ] 186 symbols loaded

[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2 (img_pil, img_ffpyplayer ignored)

[INFO   ] [Text        ] Provider: sdl2

[INFO   ] [Window      ] Provider: sdl2

[INFO   ] [GL          ] Using the "OpenGL" graphics system

[INFO   ] [GL          ] GLEW initialization succeeded

[INFO   ] [GL          ] Backend used <glew>

[INFO   ] [GL          ] OpenGL version <b'4.6.0 - Build 27.20.100.8935'>

[INFO   ] [GL          ] OpenGL vendor <b'Intel'>

[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) UHD Graphics 620'>

[INFO   ] [GL          ] OpenGL parsed version: 4, 6

[INFO   ] [GL          ] Shading version <b'4.60 - Build 27.20.100.8935'>

[INFO   ] [GL          ] Texture max size <16384>

[INFO   ] [GL          ] Texture max units <32>

[WARNING] [Image       ] Unable to load image <E:\KV\kv-demo-env\lib\site-packages\kivy\data\glsl\default.png>

[CRITICAL] [Window      ] Unable to find any valuable Window 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 - Exception: SDL2: Unable to load image

  File "E:\KV\kv-demo-env\lib\site-packages\kivy\core\__init__.py", line 70, in core_select_lib

    cls = cls()

  File "E:\KV\kv-demo-env\lib\site-packages\kivy\core\window\window_sdl2.py", line 152, in __init__

    super(WindowSDL, self).__init__()

  File "E:\KV\kv-demo-env\lib\site-packages\kivy\core\window\__init__.py", line 982, in __init__

    self.create_window()

  File "E:\KV\kv-demo-env\lib\site-packages\kivy\core\window\window_sdl2.py", line 311, in create_window

    super(WindowSDL, self).create_window()

  File "E:\KV\kv-demo-env\lib\site-packages\kivy\core\window\__init__.py", line 1268, in create_window

    self.render_context = RenderContext()

  File "kivy\graphics\instructions.pyx", line 783, in kivy.graphics.instructions.RenderContext.__init__

  File "E:\KV\kv-demo-env\lib\site-packages\kivy\core\image\__init__.py", line 561, in __init__

    self.filename = arg

  File "E:\KV\kv-demo-env\lib\site-packages\kivy\core\image\__init__.py", line 756, in _set_filename

    mipmap=self._mipmap, nocache=self._nocache)

  File "E:\KV\kv-demo-env\lib\site-packages\kivy\core\image\__init__.py", line 460, in load

    im = loader(filename, **kwargs)

  File "E:\KV\kv-demo-env\lib\site-packages\kivy\core\image\__init__.py", line 223, in __init__

    self._data = self.load(filename)

  File "E:\KV\kv-demo-env\lib\site-packages\kivy\core\image\img_sdl2.py", line 47, in load

    raise Exception('SDL2: Unable to load image')


[CRITICAL] [App         ] Unable to get a Window, abort.


分享到:
精彩评论 3
midi
学分:4 LV1
2021-07-13
沙发

这么久了都没人回复啊?    

midi
学分:4 LV1
2021-08-02
板凳

明日要凉

C灵C
学分:72 LV3
2021-10-15
地板

安装这个包了嘛? kivy.deps.sdl2

或者重新安装kivy

首页上一页 1 下一页尾页 3 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照