Debugging with faulthandler

I have a program that is giving me a segmentation fault error (“exits with…-11”), and this happens both in the PsychoPy Coder environment as well as in Spyder. Since each is using completely different Python installations, I’m not certain if the segfaults in Spyder are the same as the segfaults in Psychopy.

In Spyder, I can use faulthandler to get a verbose report when it segfaults, showing me which line of which file led to the crash, but I haven’t been able to do the same in Coder.

In Spyder, I use faulthandler by launching the main program with this script:

import os
os.system('python3 -Xfaulthandler ScamDetectionROItester2bDebug.py')

…but that doesn’t work in Coder. When I try it in Coder, I get this error:

Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000000020118f600 (most recent call first):
################ Experiment ended with exit code 0 [pid:56786] ################

PsychoPy v2022.1.3

P.S. from the Coder shell, I can import encodings just fine.