PyAudio IOError: No Default Input Device Available

后端 未结 5 2191
臣服心动
臣服心动 2020-12-06 04:11

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

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


        
5条回答
  •  眼角桃花
    2020-12-06 04:51

    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
    

提交回复
热议问题