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:
-
Single-routine version: one routine inside a loop, with one audio and two alternating visual stimuli → works fine.
-
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] #########