x11 - ImportError:没有名为' kivy.core.window.window_x11'

时间:2017-08-06 07:47:22

标签: python python-3.x kivy kivy-language

当我尝试在我的kali linux操作系统中使用python 3.5运行任何kivy程序时。然后我得到以下错误。

程序: -

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.relativelayout import RelativeLayout

Builder.load_string('''
<hey>:
    RelativeLayout:
        Button:
            text:"Hey"
''')

class hey(RelativeLayout):
    pass

class helloApp(App):
    def build(self):
        return hey()

if __name__=="__main__":
    helloApp().run()

错误: -

[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 59, 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 67, in core_select_lib
    cls = cls()
  File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 138, in __init__
    super(WindowSDL, self).__init__()
  File "/usr/lib/python3/dist-packages/kivy/core/window/__init__.py", line 722, in __init__
    self.create_window()
  File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 237, in create_window
    self.fullscreen, resizable, state)
  File "kivy/core/window/_window_sdl2.pyx", line 94, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy/core/window/_window_sdl2.c:2204)

x11 - ImportError: No module named 'kivy.core.window.window_x11'
  File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)

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

当我在之前的kali linux操作系统中安装kivy时,它曾经工作正常,但由于某些原因我再次安装kali并再次使用kivy,但这次我无法使其工作。

4 个答案:

答案 0 :(得分:3)

在我的情况下,这是一个过时的kivy版本。我看到你也在运行python3。删除kivy后,我做了以下解决了我的问题:

 sudo add-apt-repository ppa:kivy-team/kivy
 sudo apt-get update
 sudo apt-get install python3-kivy

答案 1 :(得分:2)

在Ubuntu 19.04上,我基本上遇到了相同的错误(错误消息略有不同)

...
[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
egl_rpi - ImportError: cannot import name 'bcm' from 'kivy.lib.vidcore_lite' (/usr/lib/python3/dist-packages/kivy/lib/vidcore_lite/__init__.py)
  File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 63, 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

即使尝试了这些答案中的建议,错误仍然存​​在。即使使用Kivy website中的“稳定”程序包也无济于事,我必须承认这有点令人失望。

对我有用的是通过pip3安装Kivy软件包,但这还需要一些依赖项:

# remove the old packages
sudo apt-get remove --purge *kivy*

# install some dependencies for the package build
sudo apt-get install libav-dev libsdl2-dev libavformat-dev libavdevice-dev

# Install the kivy modules with `pip3` (assuming pip3 is installed already)
sudo pip3 install ffpyplayer
sudo pip3 install kivy
sudo pip3 install kivy-examples

我刚安装了pip3,可能需要安装更多依赖项。

答案 2 :(得分:1)

pip install git+https://github.com/kivy/kivy.git@master

它对我来说就像一种魅力。

答案 3 :(得分:0)

在Ubuntu 18.04.1。上运行我的第一个python3-kivy(v1.11.1)应用程序时遇到类似的情况。

以下是我的错误日志:

[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 egl_rpi - ImportError: cannot import name 'bcm'
File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 63, 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 - ImportError: libSDL2_image-2.0.so.0: cannot open shared object file: No such file or directory
File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 27, in <module>
from kivy.core.window._window_sdl2 import _WindowSDL2Storage

x11 - ModuleNotFoundError: No module named 'kivy.core.window.window_x11'
File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)

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

对我有用的解决方案:

尝试安装python3-sdl2。 sudo apt-get install python3-sdl2并重新运行您的应用程序。

额外:设置python3-kivy并非一帆风顺。因此,在运行我的第一个应用程序之前,我将提出完整的安装步骤。希望它可以帮助某人:

# Install the dependencies
sudo apt-get install python3-setuptools libsdl2-dev libavformat-dev libavdevice-dev python3-sdl2

# Install python3-kivy via ppa. Pip install didn't work for me.
sudo add-apt-repository ppa:kivy-team/kivy
sudo apt-get update
sudo apt-get install python3-kivy

# Install ffpyplayer
python3 -m pip install ffpyplayer

# Run the app
python3 main.py