Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
723 views
in Technique[技术] by (71.8m points)

python - PyAudio IOError: No Default Input Device Available

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"

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...