【发布时间】:2015-01-21 10:14:25
【问题描述】:
当我通过命令行直接执行下面的命令时,它可以正常工作:
mpg321 -a bluetooth Canon.mp3
但是,通过 Python 执行以下代码:
import os
os.system('mpg321 -a bluetooth Canon.mp3')
我收到以下错误:
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) 未知的 PCM 蓝牙 无法使用设备蓝牙打开 libao 驱动(设备是否在使用中?)
知道可能出了什么问题吗? 谢谢!
【问题讨论】:
-
这可能是因为运行
os.system(...)的用户没有写入/dev/audio 的权限。解决方法见the Debian SoundFAQ(搜索“无法打开libao”)指向wiki.debian.org/SoundConfiguration。 -
好主意。 os.system('sudo -u pi mpg321 -a bluetooth Canon.mp3') 解决了这个问题!谢谢!请发布答案,以便我接受!
-
太棒了。很高兴它成功了。
标签: python operating-system ubuntu-14.04