| Reference | Downloads | Github

KeyError: Participant

OS: Win10
PsychoPy v: v3.0.0b9

Error message:

Traceback (most recent call last):
File “C:\Users\rahmanf2\Desktop\Magic_Cups_v2\”, line 35, in
filename = thisDir + os.sep + u’data/%s%s_%s’ % (expInfo[‘participant’], expName, expInfo[‘date’])
KeyError: ‘participant’

Hi, the above error message is appearing but I am not sure what it is referring to? I recognise that this is an error with how the participant data files are being saved/arranged. But I am not sure more precisely what the problem is.

Thank you very much. Foyzul.

Hi Foyzul,
a key error occurs whenever a dict() object is requested and the key is not in the dictionary. In this case, the key 'participant' is not in the dictionary expInfo, which is filled by the info dialog in the beginning of the experiment. You can edit this info dialog by clicking on Experiment settings (blue screen with arrows) in Builder. By default, there are fields for session and participant. Could it be that you deleted or changed the latter? If it was missing, the experiment would produce the error that you posted while generating the filename.
In order to solve the problem, you could either add the participant field again or remove the expInfo[‘participant’] part from the Data filename field in the Data tab of the same window.

1 Like

Hi there,

Thank you v. much for your help. It turned out to be a small (and silly) error on my part. The ‘p’ in the ‘participant’ field in experiment settings was capitalised. Since PsychoPy is case sensitive, it could not find the field.

Thanks, Foyzul.