PyAudio IOError:没有可用的默认输入设备 [英] PyAudio IOError: No Default Input Device Available

查看:109
本文介绍了PyAudio IOError:没有可用的默认输入设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 10.10 x64 的 Enthought Python Distribution (Python 2.6.6) 下使用 PyAudio.

<预><代码>>>>导入pyaudio>>>pa = pyaudio.PyAudio()>>>pa.get_default_input_device_info()回溯(最近一次调用最后一次):文件<pyshell#24>",第 1 行,在 <module> 中pa.get_default_input_device_info()文件/usr/lib/python_epd/lib/python2.6/site-packages/pyaudio.py",第 936 行,在 get_default_input_device_infodevice_index = pa.get_default_input_device()IOError: 没有可用的默认输入设备

这与我尝试打开输入流时遇到的错误相同.有对应的错误IOError: No Default Output Device Available"

解决方案

好的,这里有一个不漂亮但对我有用的解决方案.根据我对 ulidtko 回答的评论,pyaudio 不是问题,而是 pyaudio 应该绑定到的底层 PortAudio.

在 ubuntu 上,portaudio 驱动程序与此软件包一起安装:

sudo apt-get install python-gnuradio-audio-portaudio

你必须已经有了这个,因为你说你的股票 ubuntu 运行你的代码很好(尽管有一些可以忽略的调试消息)

如果你在运行enthought的python时查询你的portaudio模块的位置,你会发现以下内容:

<预><代码>>>>导入pyaudio>>>pyaudio.pa.__file__'/opt/epd-7.2-2-rh5-x86_64/lib/python2.7/site-packages/_portaudio.so'

以及以下关于 ubuntu 的内容:

在[1]中:导入pyaudio在 [2]: pyaudio.pa.__file__输出[2]:'/usr/lib/pymodules/python2.7/_portaudio.so'

我将 enthought _portaudio.so 移开,并用指向系统 _portaudio.so 的链接替换它,现在包括 chaco demo/advanced 目录中可爱的频谱分析仪在内的所有内容都可以正常工作:

cd/opt/epd-7.2-2-rh5-x86_64/lib/python2.7/site-packages/mv _portaudio.so _portaudio.so.originalEPDln -s/usr/lib/pymodules/python2.7/_portaudio.so

I'm using PyAudio under the Enthought Python Distribution (Python 2.6.6) in Ubuntu 10.10 x64.

>>> import pyaudio
>>> pa = pyaudio.PyAudio()
>>> pa.get_default_input_device_info()

Traceback (most recent call last):
  File "<pyshell#24>", line 1, in <module>
    pa.get_default_input_device_info()
  File "/usr/lib/python_epd/lib/python2.6/site-packages/pyaudio.py", line 936, in get_default_input_device_info
    device_index = pa.get_default_input_device()
IOError: No Default Input Device Available

This is the same error I get if I try to open an input stream. There is the corresponding error "IOError: No Default Output Device Available"

解决方案

OK, here is a solution that isn't pretty but works for me. As per my comment to ulidtko's answer, pyaudio is not the problem but rather the underlying PortAudio that pyaudio is supposed to bind to.

On ubuntu the portaudio drivers are installed with this package:

sudo apt-get install python-gnuradio-audio-portaudio

You must have this already, since you said your stock ubuntu runs your code fine (albeit with some debug messages that can be ignored)

If you query the location of your portaudio module you will find the following when you are running enthought's python:

>>> import pyaudio
>>> pyaudio.pa.__file__
'/opt/epd-7.2-2-rh5-x86_64/lib/python2.7/site-packages/_portaudio.so'

and the following on stock ubuntu:

In [1]: import pyaudio
In [2]: pyaudio.pa.__file__
Out[2]: '/usr/lib/pymodules/python2.7/_portaudio.so'

I moved the enthought _portaudio.so out of the way and replaced it with a link to the system _portaudio.so and now everything including the lovely spectrum analyzer in the chaco demo/advanced directory works:

cd /opt/epd-7.2-2-rh5-x86_64/lib/python2.7/site-packages/
mv _portaudio.so _portaudio.so.originalEPD
ln -s /usr/lib/pymodules/python2.7/_portaudio.so

这篇关于PyAudio IOError:没有可用的默认输入设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆