NameError: name 'body_file' is not defined

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

OS (e.g. Win10): macOS 10.15.7
PsychoPy version (e.g. 1.84.x): v2021.1.3
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:
I am new to psychopy and I am trying to create an experiment where expinfo “gender” (the gender at the start of the experiment will call up the relevant stimuli for the experiment. e.g. male see male stimuli, female see female stimuli etc )
whenever i try to run the experiment i get the following error message

Traceback (most recent call last):
File “/Users/akanshanaraindas/PHD First year/Body transformation task 2/body transformation task (1)_lastrun.py”, line 609, in
Body.setImage(body_file)
NameError: name ‘body_file’ is not defined

What did you try to make it work?:
added a begin experiment code component: condsFile=‘chooseblocks’+str(expInfo[‘Gender’])+’.xlsx’ with a trial loop with “$condsFile” in the conditions field

my excel files are designed where there are 3 chooseblocks files “chooseblocksF.xlsx” “chooseblocksM.xlsx” and “chooseblocksNonBinary.xlsx” which have a column headed “condsFile” which have the names of other xlsx files which have the pathways for the images to be presented so: (maleBlock.xlsx, femaleBlock.xlsx etc) these files have the pathways of the images under a column headed body_file with pathways like “Images/Female/BACKFACING_LH_OW_0.png”

and In the routine i have an image component with $body_file in the image field set to every repeat.

What specifically went wrong when you tried that?:
Traceback (most recent call last):
File “/Users/akanshanaraindas/PHD First year/Body transformation task 2/body transformation task (1)_lastrun.py”, line 609, in
Body.setImage(body_file)
NameError: name ‘body_file’ is not defined
body transformation task (1).psyexp (34.3 KB)

I assume body_file is in your spreadsheets. Are you using it in a parameter set to constant instead of each repeat?

Continuing the discussion from NameError: name 'body_file' is not defined:

yes its in the spreadsheets that are directed to through chooseblocks files, body_file is also set every repeat in the image component. - i have attached the spreadsheet to help understand. I also attached the psyexp file in my original post as there are quite a few levels to the study and it gets confusing
maleBlock.xlsx (9.1 KB)