我是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
我已经使用
安装了kivysudo apt-get install python3-kivy
我错过了什么吗?当我搜索这些错误时,我发现有人建议安装pygame,但这似乎是一个死的项目?
答案 0 :(得分:3)
这个问题也发生在16.04对我来说。
我的解决方案,删除ubuntu软件包(在保存方面)并使用pip安装:
sudo apt-get remove python3-kivy
sudo pip3 install kivy
答案 1 :(得分:1)
正如inclement在他的评论中所说,切换到kivy-daily解决了这个问题!我不得不在我的机器上进行dist-upgrade来解决一些依赖关系。
答案 2 :(得分:1)
我的解决方案与Sebastian相似,但适用于Python 2.7。
sudo apt-get remove python-kivy
sudo pip install kivy
sudo pip install pygame
答案 3 :(得分:0)
我刚从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 with pip3,然后就可以使用python3
答案 4 :(得分:0)
由misakеsdl2
-TypeError: expected bytes, str found
sdl2 dependency
的安装帮助我:
sudo apt-get install python3-sdl2