如何用Python 3运行Kivy? Kivy错误:“无法find任何有价值的窗口提供程序”

我想在VirtualBox的Ubuntu 16.04上使用Python 3 kivy

但是,当我尝试使用Python 3:运行以下最小代码时Python 3:

 from kivy.app import App from kivy.uix.label import Label class TestApp(App): def build(self): return Label(text="hello kivy") TestApp().run() 

我得到下面的错误。

 $ python3 test.py [INFO ] [Logger ] Record log in /home/openstack/.kivy/logs/kivy_16-10-08_7.txt [INFO ] [Kivy ] v1.9.0 [INFO ] [Python ] v3.5.2 (default, Sep 10 2016, 08:21:44) [GCC 5.4.0 20160609] [INFO ] [Factory ] 173 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored) [INFO ] [Text ] Provider: sdl2 [INFO ] [OSC ] using <multiprocessing> for socket [INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored) [CRITICAL] [Window ] Unable to find any valuable Window provider at all! egl_rpi - ImportError: cannot import name 'bcm' File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 57, in core_select_lib fromlist=[modulename], level=0) File "/usr/lib/python3/dist-packages/kivy/core/window/window_egl_rpi.py", line 12, in <module> from kivy.lib.vidcore_lite import bcm, egl sdl2 - TypeError: expected bytes, str found File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 65, in core_select_lib cls = cls() File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 121, in __init__ super(WindowSDL, self).__init__() File "/usr/lib/python3/dist-packages/kivy/core/window/__init__.py", line 616, in __init__ self.create_window() File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 171, in create_window self.fullscreen, resizable, state) File "kivy/core/window/_window_sdl2.pyx", line 60, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy/core/window/_window_sdl2.c:1447) x11 - ImportError: No module named 'kivy.core.window.window_x11' File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 57, in core_select_lib fromlist=[modulename], level=0) [CRITICAL] [App ] Unable to get a Window, abort. Exception ignored in: 'kivy.properties.dpi2px' Traceback (most recent call last): File "/usr/lib/python3/dist-packages/kivy/utils.py", line 360, in __get__ retval = self.func(inst) File "/usr/lib/python3/dist-packages/kivy/metrics.py", line 169, in dpi EventLoop.ensure_window() File "/usr/lib/python3/dist-packages/kivy/base.py", line 126, in ensure_window sys.exit(1) SystemExit: 1 [CRITICAL] [App ] Unable to get a Window, abort. 

虽然在Python 2:下运行相同的代码没有问题Python 2:

 $ python test.py [INFO ] [Logger ] Record log in /home/openstack/.kivy/logs/kivy_16-10-08_11.txt [INFO ] [Kivy ] v1.9.0 [INFO ] [Python ] v2.7.12 (default, Jul 1 2016, 15:12:24) [GCC 5.4.0 20160609] [INFO ] [Factory ] 173 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored) [INFO ] [Text ] Provider: sdl2 [INFO ] [OSC ] using <multiprocessing> for socket [INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored) [INFO ] [GL ] OpenGL version <3.0 Mesa 11.2.0> [INFO ] [GL ] OpenGL vendor <VMware, Inc.> [INFO ] [GL ] OpenGL renderer <Gallium 0.4 on llvmpipe (LLVM 3.8, 256 bits)> [INFO ] [GL ] OpenGL parsed version: 3, 0 [INFO ] [GL ] Shading version <1.30> [INFO ] [GL ] Texture max size <8192> [INFO ] [GL ] Texture max units <18> [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 available [INFO ] [Base ] Leaving application in progress... 

任何build议如何运行与Python 3的Kivy?

顺便说一句,以下安装成功:

 $ sudo apt-get install libsdl2-2.0-0 libsdl2-image-2.0-0 libsdl2-mixer-2.0-0 libsdl2-ttf-2.0-0 $ sudo apt-get install python3-pil $ sudo apt-get install python-setuptools python-pygame python-opengl python-gst0.10 python-enchant gstreamer0.10-plugins-good python-dev build-essential libgl1-mesa-dev libgles2-mesa-dev python-pip libgstreamer1.0-dev