from kivy.app import Appfrom kivy.uix.button import Buttonclass TestApp(App): def build(self): return Button(text="Hello,kivy") TestApp().run()1234567
输出结果:
[INFO ] [Logger ] Record log in C:Usersusth1.kivylogskivy_17-06-09_17.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_pil, img_gif (img_sdl2, img_ffpyplayer ignored)[INFO ] [Text ] Provider: pil(["text_sdl2"] ignored)[CRITICAL] [Window ] Unable to find any valuable Window provider. sdl2 - ImportError: DLL load failed: 找不到指定的模块。 File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivycore\__init__.py", line 59, in core_select_lib fromlist=[modulename], level=0) File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivycorewindowwindow_sdl2.py", line 26, in <module> from kivy.core.window._window_sdl2 import _WindowSDL2Storage[CRITICAL] [App ] Unable to get a Window, abort. Exception ignored in: "kivy.properties.dpi2px" Traceback (most recent call last): File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivyutils.py", line 496, in __get__ retval = self.func(inst) File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivymetrics.py", line 174, in dpi EventLoop.ensure_window() File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivyase.py", line 127, in ensure_window sys.exit(1) SystemExit: 1[CRITICAL] [App ] Unable to get a Window, abort. ------------------ (program exited with code: 1) 请按任意键继续. . .123456789101112131415161718192021222324252627282930
接着我在GitHub上查询了相关文档:
https://github.com/kivy/kivy/issues/3889
下载了kivy.deps.sdl2:
C:Usersusth1>pip install kivy.deps.sdl2
输出结果:
[INFO ] [Logger ] Record log in C:Usersusth1.kivylogskivy_17-06-09_16.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_sdl2, img_pil, img_gif (img_ffpyplayer ignored)[INFO ] [Text ] Provider: sdl2[INFO ] [OSC ] using <thread> for socket[INFO ] [Window ] Provider: sdl2[CRITICAL] [Window ] Unable to find any valuable Window provider. sdl2 - ImportError: DLL load failed: 找不到指定的模块。 File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivycore\__init__.py", line 67, in core_select_lib cls = cls() File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivycorewindowwindow_sdl2.py", line 140, in __init__ super(WindowSDL, self).__init__() File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivycorewindow\__init__.py", line 899, in __init__ self.create_window() File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivycorewindowwindow_sdl2.py", line 269, in create_window self.fullscreen, resizable, state) File "kivycorewindow\_window_sdl2.pyx", line 110, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivycore/window\_window_sdl2.c:2466) File "kivygraphicscgl.pyx", line 52, in kivy.graphics.cgl.cgl_get_backend_name (kivygraphicscgl.c:3044) File "kivygraphicscgl.pyx", line 60, in kivy.graphics.cgl.cgl_get_backend_name (kivygraphicscgl.c:2879) File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libimportlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 648, in _load_unlocked File "<frozen importlib._bootstrap>", line 560, in module_from_spec File "<frozen importlib._bootstrap_external>", line 922, in create_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed[CRITICAL] [App ] Unable to get a Window, abort. Exception ignored in: "kivy.properties.dpi2px" Traceback (most recent call last): File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivyutils.py", line 496, in __get__ retval = self.func(inst) File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivymetrics.py", line 174, in dpi EventLoop.ensure_window() File "C:Usersusth1AppDataLocalProgramsPythonPython36-32libsite-packageskivyase.py", line 127, in ensure_window sys.exit(1) SystemExit: 1[CRITICAL] [App ] Unable to get a Window, abort. ------------------ (program exited with code: 1) 请按任意键继续. . .123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
还是有错误,接下来在stackoverflow上查询文档:
https://stackoverflow.com/questions/40769386/kivy-windows-unable-to-find-any-valuable-window-provider-at-all
下载python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
运行结果:
Purge log fired. Analysing... Purge finished! [INFO ] [Logger ] Record log in C:Usersusth1.kivylogskivy_17-06-09_19.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_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Text ] Provider: sdl2 [INFO ] [OSC ] using <thread> for socket [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.4.0 - Build 21.20.16.4627">[INFO ] [GL ] OpenGL vendor <b"Intel">[INFO ] [GL ] OpenGL renderer <b"Intel(R) HD Graphics 530">[INFO ] [GL ] OpenGL parsed version: 4, 4[INFO ] [GL ] Shading version <b"4.40 - Build 21.20.16.4627">[INFO ] [GL ] Texture max size <16384> [INFO ] [GL ] Texture max units <32> [INFO ] [Shader ] fragment shader: <b"WARNING: 0:7: "" : #version directive missing"> [INFO ] [Shader ] vertex shader: <b"WARNING: 0:7: "" : #version directive missing"> [INFO ] [Window ] auto add sdl2 input provider [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked [INFO ] [Base ] Start application main loop[INFO ] [GL ] NPOT texture support is available123456789101112131415161718192021222324252627
成功!
暂无评论,还不快来坐沙发...