Need help with this error in the loop

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Mac
PsychoPy version (e.g. 1.84.x): 2022.2.5
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:
I am trying to insert an outer loop to randomize blocks of my stimuli. My condition file is this.
condsFile.xlsx (8.6 KB)

and when I run my experiment, I keep getting this message “UnboundLocalError: local variable ‘trialList’ referenced before assignment”

This is my experiment file.
SeoulKr_stopC_psychopy_image_button.psyexp (241.1 KB)

What did you try to make it work?:
I tried

  • converting to .csv and .xlsx.
  • recreating and saving the condition file.
  • removing space in cells

Please help me with me. I don’t know what’s the problem here.

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information


Based on the error message, part of the experiment is not able to access some loop information (trialList) correctly. There are a lot of loops in the experiment, so I can’t tell if one or all are experiencing the problem. When there are problems with loops, there are a couple things I like to check:

  • Are components which should change every trial are set to “update on repeat” instead of “constant”?
  • Online-only: you might need to manually specify the multiple conditions files in ‘Additional Resources’

If there are still issues after that, a more complete error message with the line numbers might help narrow down which loop is currently running into problems.


Thank you so much. I added all the files (audio, images and condition files) to ‘Additional Recourses’, and it worked!

1 Like