无法在Ubuntu上运行Kivy

4zcjmb1e  于 2023-04-29  发布在  其他
关注(0)|答案(6)|浏览(99)

我是python和kivy的新手,我想运行我的第一个kivy程序。当我运行程序时,我得到这个错误:

/usr/bin/python3.4 /home/mmu/PycharmProjects/ShipControl/gui/gui.py
[INFO              ] [Logger      ] Record log in /home/mmu/.kivy/logs/kivy_15-11-29_0.txt
[INFO              ] [Kivy        ] v1.9.0
[INFO              ] [Python      ] v3.4.3+ (default, Oct 14 2015, 16:03:50) 
[GCC 5.2.1 20151010]
[INFO              ] [Factory     ] 173 symbols loaded
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[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:1379)

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.

Process finished with exit code 1

我已经安装了kivy使用

sudo apt-get install python3-kivy

我错过什么了吗?当我搜索这些错误时,我发现有人建议安装pygame,但这似乎是一个死项目?

hujrc8aj

hujrc8aj1#

这个问题也发生在16。04为我。
我的解决方案是,删除ubuntu软件包(保存在保存一边)并使用pip安装:

sudo apt-get remove python3-kivy
sudo pip3 install kivy
xnifntxz

xnifntxz2#

我刚从git上安装了kivy,这是我的bash_history

sudo apt-get install git
mkdir ~/code
cd ~/code
git clone http://github.com/kivy/kivy
cd kivy/
wget http://bootstrap.pypa.io/get-pip.py
python get-pip.py --user
export PATH=$PATH:~/.local/bin/
pip install cython --user
sudo apt-get install python-dev
sudo apt-get install libgles2-mesa-dev
pip install cython --user
sudo apt-get install libgles1-mesa-dev
sudo apt-get install libsdl2-dev     libsdl2-image-dev     libsdl2-mixer-dev     libsdl2-ttf-dev     libportmidi-dev     libswscale-dev     libavformat-dev     libavcodec-dev     zlib1g-dev
make
export PYTHONPATH=~/code/kivy/
pip install pygments --user
pip install docutils --user
python examples/demo/showcase/main.py

对于使用python3,只需将make替换为python3 build_ext --inplace pip替换为pip3,然后就可以使用python3运行了

j9per5c4

j9per5c43#

正如他在评论中所说的那样,切换到kivy-daily解决了这个问题!我不得不在我的机器上做一个dist-upgrade来解决一些依赖关系。

zc0qhyus

zc0qhyus4#

我的解决方案与塞巴斯蒂安的类似,但适用于Python 2。7.

sudo apt-get remove python-kivy
sudo pip install kivy
sudo pip install pygame
ddhy6vgd

ddhy6vgd5#

判断错误е sdl2-TypeError: expected bytes, str found
sdl2 dependency的安装帮助了我:sudo apt-get install python3-sdl2

li9yvcax

li9yvcax6#

我已经安装了这里提到的每个包。..对我来说,解决的问题是导出显示(我在橙子Pi上通过VNC连接)

export DISPLAY=:0

相关问题