Version: PsychoPy 2021.1.2
When I try to put the name of a variable in the “allowed keys” field of the keyboard component in builder I get the error message below, saying that the name of the variable is not defined and “allowed keys list is invalid”.
The variable is defined in a “begin experiment” tab of a code component like so: keys1 = [‘1’,‘2’,‘3’] I have also tried to give a variable defined in an excel sheet. Same error.
I think I am doing everything correctly with the code and interface components, so I’m guessing it is a problem with builder?
Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\keyboard_init_.py”, line 238, in writeFrameCode
keyList = eval(allowedKeys)
File “”, line 1, in
NameError: name ‘keys1’ is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py”, line 1165, in runFile
self.app.runner.panel.runLocal(event)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\runner\runner.py”, line 635, in runLocal
exp=self.loadExperiment())
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 73, in generateScript
compileScript(infile=exp, version=None, outfile=filename)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 242, in compileScript
_makeTarget(thisExp, outfile, targetOutput)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 221, in makeTarget
script = thisExp.writeScript(outfile, target=targetOutput)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment_experiment.py”, line 212, in writeScript
self_copy.flow.writeBody(script)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\flow.py”, line 217, in writeBody
entry.writeMainCode(script)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\routine.py”, line 206, in writeMainCode
event.writeFrameCode(buff)
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\keyboard_init.py", line 241, in writeFrameCode
self.params[“name”], “Allowed keys list is invalid.”)
psychopy.experiment.utils.CodeGenerationException: key_resp_7: