PyAudio cannot find any output devices

北战南征 提交于 2021-02-04 12:36:05

问题


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:


回答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 ;-)




回答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



回答3:


Install with apt-get; and run with python2. Or install with conda and run with python3.



来源:https://stackoverflow.com/questions/42404408/pyaudio-cannot-find-any-output-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!