我如何才能让Kivy在Linux上使用sdl2? [英] How can I get Kivy to use sdl2 on Linux?
问题描述
我遇到了一个问题,其中Kivy在android上使用sdl2,并且工作正常,但是在linux上,它使用ffpyplayer,而事实并非如此.
I've got a problem where Kivy uses sdl2 on android, and works fine, but on linux it uses ffpyplayer, which doesn't.
所以我也想让Kivy在Linux上也使用sdl2,但是sdl2在Linux上似乎根本不起作用.
So I'd like to get Kivy to use sdl2 on linux too, however sdl2 doesn't seem to work at all on linux.
$ KIVY_AUDIO=sdl2 python min_audio_example.py
[INFO ] [Audio ] Providers: audio_sdl2 (audio_ffpyplayer ignored)
[CRITICAL] [AudioSDL2 ] Unable to open mixer: b'No such audio device'
这是一个演示问题的最小示例.
Here's a minimal example with demonstrates the problem.
#!/usr/bin/env python
# works with:
# export KIVY_AUDIO=ffpyplayer
# fails with:
# export KIVY_AUDIO=sdl2
from kivy.app import App
from kivy.core.audio import SoundLoader
def playsound(dummy):
sound = SoundLoader.load("440Hz_44100Hz_16bit_05sec.ogg")
if sound:
print("Sound found at %s" % sound.source)
print("Sound is %.3f seconds" % sound.length)
print("sound state", sound.state)
sound.play()
print("sound state", sound.state)
import time
time.sleep(5)
class TestApp(App):
playsound(None)
if __name__ == '__main__':
TestApp().run()
我认为这可能与猕猴桃轮的构造有关,所以我尝试了
I think it might be something to do with how the kivy wheel is built, so I tried
pip uninstall kivy
pip install -U --no-binary=:all: kivy
那时候,kivy似乎根本看不到sdl2!
At that point, kivy doesn't seem to see sdl2 at all!
$ KIVY_AUDIO=sdl2 python min_audio_example.py
[INFO ] [Audio ] Providers: (audio_ffpyplayer, audio_pygame ignored)
[WARNING] [Audio ] Unable to find a loader for </home/john/data/sight-sing/sightsinger/440Hz1secfadeinandout.ogg>
它现在将audio_ffpyplayer和audio_pygame列为提供程序,并且由于环境变量而未使用任何一个. (pygame提供程序似乎也坏了,但是ffpyplayer仍然可以工作)
It's now listing audio_ffpyplayer, and audio_pygame as providers, and not using either because of the environment variable. (The pygame provider also seems broken, but ffpyplayer still works)
任何人都可以帮忙吗?
推荐答案
这是千篇一律的车轮构造,而我尝试的修复几乎是正确的.
It is the kivy wheel build, and my attempted fix was nearly right.
问题是,如果kivy是在缺少依赖项的情况下构建的,那么它将在不支持任何事物的情况下进行构建,但不会抱怨.
The problem is that if kivy is built with a missing dependency, it will build without support for things, but not complain.
因此,在debian上,安装kivy的依赖项:
So, on debian, install kivy's dependencies:
( https://kivy. org/doc/stable/installation/installation-linux-venvs.html#installation-in-venv )
sudo apt-get install python-pip build-essential git python python-dev ffmpeg libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev zlib1g-dev
然后:
pip uninstall kivy
然后在不使用损坏的预制轮的情况下进行安装
then install without using the broken pre-built wheel
pip install --no-binary kivy kivy
这篇关于我如何才能让Kivy在Linux上使用sdl2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!