PTB-ERROR: PortAudio can't detect any supported sound device on this system

Hello. I’m trying to get PsychoPy working in a virtual Linux (Ubuntu 20.04) environment that doesn’t have a “real” audio input, just a virtual pulseaudio FIFO source. It works as an audio input in Audacity and Firefox, but trying to run psychopy produces the below error output which, it seems to me, has to do with the application not recognizing the input being available.

Is there a way to work around the requirement for a michophone (using the mic is not necessary in this particular case, so just disabling the check would help)? Or is there some other way to fix this issue?

pygame 2.0.2 (SDL 2.0.16, Python 3.8.10)
Hello from the pygame community. https://www.pygame.org/contribute.html
PTB-INFO: Using modified PortAudio V19.7.0-devel, revision unknown
Error in function GetDevices: 	Usage error
PTB-ERROR: PortAudio can't detect any supported sound device on this system.
PsychPortAudio:GetDevices: Usage:

devices = PsychPortAudio('GetDevices' [, devicetype] [, deviceIndex]);
Traceback (most recent call last):
  File "/usr/local/bin/psychopy", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/psychopy/app/psychopyApp.py", line 100, in main
    start_app()
  File "/usr/local/lib/python3.8/dist-packages/psychopy/app/psychopyApp.py", line 22, in start_app
    from psychopy.app._psychopyApp import PsychoPyApp
  File "/usr/local/lib/python3.8/dist-packages/psychopy/app/_psychopyApp.py", line 26, in <module>
    from . import themes
  File "/usr/local/lib/python3.8/dist-packages/psychopy/app/themes/__init__.py", line 1, in <module>
    from ._themes import ThemeMixin, IconCache
  File "/usr/local/lib/python3.8/dist-packages/psychopy/app/themes/_themes.py", line 34, in <module>
    allCompons = components.getAllComponents()  # ensures that the icons get checked
  File "/usr/local/lib/python3.8/dist-packages/psychopy/experiment/components/__init__.py", line 63, in getAllComponents
    components = getComponents(fetchIcons=fetchIcons)  # get the built-ins
  File "/usr/local/lib/python3.8/dist-packages/psychopy/experiment/components/__init__.py", line 158, in getComponents
    module = import_module(explicit_rel_path, package=pkg)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/lib/python3.8/dist-packages/psychopy/experiment/components/microphone/__init__.py", line 29, in <module>
    devices = {d.deviceName: d for d in Microphone.getDevices()}
  File "/usr/local/lib/python3.8/dist-packages/psychopy/sound/microphone.py", line 549, in getDevices
    allDevs = audio.get_devices()
  File "/usr/local/lib/python3.8/dist-packages/psychtoolbox/audio.py", line 70, in get_devices
    return PsychPortAudio('GetDevices', device_type, device_index);
Exception: PTB-ERROR: PortAudio can't detect any supported sound device on this system.
2.3410 	WARNING 	Speech-to-text recognition module not available (use command `pip install SpeechRecognition` to get it. Transcription will be unavailable.
2.3765 	WARNING 	We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use ['sounddevice', 'PTB', 'pyo', 'pygame'] (in that order).

1 Like

I have encountered the same problem. The flash screen launches but then dies.
It told me to install sounddevice which I have done but that made no difference whatsoever.
So I now have installed a system that simply fails to work.
Its a Windows installation of 2023.1.3
I am completely stumped and now cannot run any code.

Any help/advice gratefully received.
Philip.

Funnily enough we recently found this error in our test suite (which is also a Linux virtual machine). I’ve attempted to fix it by putting that call in a try loop, to essentially say “try to get devices, if PTB raises an error, convert it to a warning and continue with a blank list rather than crashing”:

In the meantime, the easiest way around this is probably to use a different audio backend until the new release. @philip.quinlan, in addition to installing sounddevice did you update the value in Experiment Settings to use sounddevice rather than ptb?

Hi I dont know how to change the experiment settings if the program fails to launch.

You can edit the psyexp file in the text editor, though actually you may be able to just go to your user folder (%AppData%/psychopy3) and delete your preferences file, meaning when the app tries to load it won’t try to load that experiment so should dodge the error