PyAudio cannot find any output devices

15,749

Solution 1

Its likely a broken file that needs replacement.

  1. Search for "/usr/./libstdc++.so.6" where pip installed it.

  2. Search for "/usr/lib/x86_64-linux-gnu/libstdc++.so.6" and copy to location at (1). This should fix it.

  3. If you have Anaconda version 3 - 4.3.0 or 4.4.0 or earlier installed then check at "anaconda3/lib/libstdc++.so.6" and replance with (2).

Alternatively A) rename the file and place the file from (2) where you renamed the old libstdc++.so.6 file or B) upgrade to Anaconda to 5.0.1 version and run conda update --all. And if you do "B" don't forget to remove the eggs or whls manually first to be sure there is no chance installing old software from there again.

This should fix it for you.

Enjoy ;-)

Solution 2

It looks like you're missing the package portaudio19-dev. Use the following command to install that package using the terminal:

sudo apt-get install portaudio19-dev
Share:
15,749
Null Salad
Author by

Null Salad

Updated on June 25, 2022

Comments

  • Null Salad
    Null Salad almost 2 years

    When I run:

    import pyaudio
    pa = pyaudio.PyAudio()
    pa.get_default_output_device_info()
    

    I get:

    IOError: No Default Output Device Available
    

    When I say:

    pa.get_device_count()
    

    It returns 0L.

    And of course if I list devices

    for i in range(0, device_count):
            print("Name: " + pa.get_device_info_by_index(i)["name"])
            print("Index: " + pa.get_device_info_by_index(i)["index"])
            print("\n")
    

    It will not print anything.

    I'm running Ubuntu 16.04 and have set my default sink by going:

    pacmd list-sinks
    pacmd set-default-sink 0
    

    I have the latest versions of PulseAudio, ALSA, and PortAudio. Any suggestions?

    Update: I also can't view any sound devices on Audacity, despite the fact that they appear under System Settings>Sound. In Audacity I get the error:

    Error while opening sound device. Please check the recording device settings and the project sample rate.

    I think that this is almost certainly a PortAudio issue since the settings page looks like: enter image description here

  • Null Salad
    Null Salad about 6 years
    In step 1, I have lib installed in many locations relative to /usr/ : /usr/lib/i386-linux-gnu/libstdc++.so.6 /usr/lib/i386-linux-gnu/libstdc++.so.6.0.22 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22 /usr/lib32/libstdc++.so.6 /usr/lib32/libstdc++.so.6.0.22 /usr/libx32/libstdc++.so.6 /usr/libx32/libstdc++.so.6.0.22 /usr/local/MATLAB/R2016a/sys/os/glnxa64/libstdc++.so.6.0.17 /usr/local/MATLAB/R2016a/sys/os/glnxa64/libstdc++.so.6.old /usr/share/gdb/auto-load/usr/lib/i386-linux-gnu/libstdc++.so‌​.6.0.22-gdb.py Which should I choose?
  • Null Salad
    Null Salad about 6 years
    (Sorry for the ugly formatting above, I also had to remove a few under usr/share/.. for space requirements that I considered may have been irrelevant :P)
  • ZF007
    ZF007 about 6 years
    Its indeed a lot. However, I use values 1-11 to name each individual path in this stack mentioned. Rename them with "old" when replacing. Replace 1, 5, 7, 10 with 3. and 2, 6, 8, 9 with 4. "11" seems a python file or is that a typo? If that still doesn't work try to replace all accordingly with 1 and 2 or with 5, 6 or 7, 8. Alternatively you can replace them all with just 3 if all previous options don't work.. Time consuming it is this type of debugging ;-(
  • Null Salad
    Null Salad about 6 years
    OMG. I did this, AND also re-installed portaudio manually (with tarballs, not apt-get) and it WORKS!!!!!!!!! THANK-YOU!
  • Null Salad
    Null Salad about 6 years
    Although when I run it I get a bunch of errors, I don't know what they mean, but it still works so I'm not complaining: ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ... ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map ... Cannot connect to server socket err = No such file or directory ... jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock ... (shortened to fit)
  • ZF007
    ZF007 about 6 years
    Good to hear it now works. U17 is coming... the pre-release is just up on the website. Depending on how much software you've got installed on U16, I have migrated every now and then to newer U-versions with fresh install, rather than updating from withing a current U-version. This approach requires just one extra HDD or SDD and an extra selection boot-option in the bootloader. This approach makes it less painful "upgrading". its a kind of hard-wired fail-safe. Also, very useful when MS comes with a complete SP (a.k.a ignores the default restore-point software, which imo is for minor changes.)
  • Soumen Mukherjee
    Soumen Mukherjee about 5 years
    Please can you elaborate on your answers , please see this section on how to best put forward your answer stackoverflow.com/help/how-to-answer
  • Lyn
    Lyn almost 5 years
    Mine is still not OK. I just make installed PortAudio and run the test file 'pa_devs' within its dir. But the output is always "Number of devices = 0". Help!!