I’d love to hear from anyone who has sound (input, output, or both) reliably working on Linux

I’m curious to hear from people who are successfully using sound (mainly interested in playing recorded files and recording with a microphone) on any linux distribution. I had things working well for about a year but now it’s broken and I’m not entirely sure why. Frankly, we can’t do anything (in a speech perception and production lab) without sound and PsychoPy has really become a nightmare the last few years for us. I am willing to do the python development work to improve PsychoPy’s support for sound on Linux, but it would be helpful to have a clearer picture of what other people have working and how idiosyncratic my headaches have been.

So: if you have PsychoPy successfully working with sound on Linux, I’d love it if you could tell me:

What kind of physical audio device are you using?

Do you use PTB, SoundDevice, PYO, or PyGame?
What distribution do you use?

Do you use Gnome or KDE?

Wayland or X11?

Do you use PipeWire, JACK, or PulseAudio?

Does it work well or do you have strange behavior (e.g. recording a wav file results in a file with 128 tracks, Sound objects will only play 44.8k sample rate, stereo files or experiments crash at run time, etc.)


I’ll go first and describe my last known-working configuration.

What kind of physical audio device are you using: Steinberg UR-22 mkii usb audio interface

Do you use PTB, SoundDevice, PYO, or PyGame: PTB
What distribution do you use: Debian 12

Do you use Gnome or KDE: KDE, I can’t even have GNOME desktop installed or audio wouldn’t work.

Wayland or X11? X11 so that experiments can position and hide the mouse

Do you use PipeWire, JACK, or PulseAudio: I have to uninstall PipeWire and install PulseAudio to make sound work. This is also the reason I can’t use GNOME desktop, Ubuntu, PopOS, Redhat, etc. because they use PipeWire.

Hello kbmcgowan,

My setup:

  • Distribution: Ubuntu 22.04 (X11, GNOME)

  • Audio backend: PTB

  • Audio device: Onboard “HD-Audio Generic: CX8070 Analog (hw:1,0)”

  • Audio system: PulseAudio (on PipeWire 1.0.5)

  • PsychoPy version: 2026.1.0 (source build)

I also had sound problems on Linux — at first I thought it was related to the audio interface, but it turned out to be a PsychoPy issue. I discovered that PTB fails when two different routines within the same loop each contain a Sound component.

To verify, I created two minimal GUI experiments:

  1. Single-routine version: one routine inside a loop, with one audio and two alternating visual stimuli → works fine.

  2. Double-routine version: same as above but the routine is duplicated inside the loop → crashes.

So the issue doesn’t depend on the sound device itself — it seems PsychoPy/PTB cannot properly handle multiple sound routines (possibly multiple streams) within the same loop.

Hope this sheds some light on what’s going on. Let me know if you’d like me to upload the minimal experiments — I’m about to file a bug report as well.

PD: here is the traceback of succesfull experiment:

Generating PsychoPy script...

## Running: /home/joctavio/repos/psy/simple_audio/simple_audio_lastrun.py ##
919.4649     INFO     Loaded monitor calibration from ['2025_09_11 13:38']
919.5025     INFO     Loaded monitor calibration from ['2025_09_11 13:38']
Failure: No such entity
Failure: No such entity
10.2961     WARNING     Stopping key buffers but this could be dangerous ifother keyboards rely on the same.
Failure: No such entity
Failure: No such entity
############### Experiment completed [pid:22764] ###############

And here failed one:

Generating PsychoPy script...

## Running: /home/joctavio/repos/psy/simple_audio/simple_audio_lastrun.py ##
919.4649     INFO     Loaded monitor calibration from ['2025_09_11 13:38']
919.5025     INFO     Loaded monitor calibration from ['2025_09_11 13:38']
Failure: No such entity
Failure: No such entity
10.2961     WARNING     Stopping key buffers but this could be dangerous ifother keyboards rely on the same.
Failure: No such entity
Failure: No such entity
############### Experiment completed [pid:22764] ###############
1031.9866     INFO     Loaded monitor calibration from ['2025_09_11 13:38']
1032.0495     INFO     Loaded monitor calibration from ['2025_09_11 13:38']
1032.0688     INFO     Investigating repo at /home/joctavio/repos/psy
1032.0744     WARNING     We found a repository at /home/joctavio/repos/psy but it doesn't point to gitlab.pavlovia.org. You could create that as a remote to sync from PsychoPy.
Generating PsychoPy script...

## Running: /home/joctavio/repos/psy/simple_audio/simple_audio_doble_lastrun.py ##
1039.8878     INFO     Loaded monitor calibration from ['2025_09_11 13:38']
1039.9617     INFO     Loaded monitor calibration from ['2025_09_11 13:38']
Failure: No such entity
Failure: No such entity
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1742
Expression 'AlsaOpen( hostApi, parameters, streamDir, &pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1774
Exception ignored in: <function Stream.__del__ at 0x735ad4359360>
Traceback (most recent call last):
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 236, in __del__
    self.close()
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 146, in close
    raise err
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 139, in close
    PsychPortAudio('Close', self.handle)
AttributeError: 'Stream' object has no attribute 'handle'
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1742
Expression 'AlsaOpen( hostApi, parameters, streamDir, &pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1774
Exception ignored in: <function Stream.__del__ at 0x735ad4359360>
Traceback (most recent call last):
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 236, in __del__
    self.close()
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 146, in close
    raise err
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 139, in close
    PsychPortAudio('Close', self.handle)
AttributeError: 'Stream' object has no attribute 'handle'
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1742
Expression 'AlsaOpen( hostApi, parameters, streamDir, &pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1774
Exception ignored in: <function Stream.__del__ at 0x735ad4359360>
Traceback (most recent call last):
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 236, in __del__
    self.close()
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 146, in close
    raise err
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 139, in close
    PsychPortAudio('Close', self.handle)
AttributeError: 'Stream' object has no attribute 'handle'
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1742
Expression 'AlsaOpen( hostApi, parameters, streamDir, &pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1774
Exception ignored in: <function Stream.__del__ at 0x735ad4359360>
Traceback (most recent call last):
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 236, in __del__
    self.close()
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 146, in close
    raise err
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 139, in close
    PsychPortAudio('Close', self.handle)
AttributeError: 'Stream' object has no attribute 'handle'
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1742
Expression 'AlsaOpen( hostApi, parameters, streamDir, &pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1774
Exception ignored in: <function Stream.__del__ at 0x735ad4359360>
Traceback (most recent call last):
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 236, in __del__
    self.close()
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 146, in close
    raise err
  File "/home/joctavio/miniconda3/envs/psychopy-build/lib/python3.10/site-packages/psychtoolbox/audio.py", line 139, in close
    PsychPortAudio('Close', self.handle)
AttributeError: 'Stream' object has no attribute 'handle'
Traceback (most recent call last):
  File "/home/joctavio/repos/psy/simple_audio/simple_audio_doble_lastrun.py", line 972, in <module>
    run(
  File "/home/joctavio/repos/psy/simple_audio/simple_audio_doble_lastrun.py", line 420, in run
    sound_1 = sound.Sound(
  File "/home/joctavio/repos/psychopy/psychopy/sound/sound.py", line 21, in __new__
    return backend.Sound(*args, **kwargs)
  File "/home/joctavio/repos/psychopy/psychopy/sound/backend_ptb.py", line 133, in __init__
    speaker = SpeakerDevice(speaker)
  File "/home/joctavio/repos/psychopy/psychopy/hardware/speaker.py", line 112, in __init__
    self.createStream()
  File "/home/joctavio/repos/psychopy/psychopy/hardware/speaker.py", line 247, in createStream
    raise ConnectionError(
ConnectionError: Failed to setup a PsychToolBox audio stream for device HD-Audio Generic: CX8070 Analog (hw:1,0) (0.0).
Failure: No such entity
Failure: No such entity
11.3559     WARNING     Stopping key buffers but this could be dangerous ifother keyboards rely on the same.
######## Experiment ended with exit code 1 [pid:22915] #########