How can I deal with this error?

OS** (e.g. Win10): Win10
PsychoPy version** (e.g. 1.84.x): v2021.2.3

Traceback (most recent call last):
File “D:\psychopy 2021.2.3\lib\site-packages\psychopy\experiment\components\”, line 245, in writeFrameCode
keyList = eval(allowedKeys)
File “”, line 1
SyntaxError: EOL while scanning string literal

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “D:\psychopy 2021.2.3\lib\site-packages\psychopy\app\builder\”, line 1192, in runFile
File “D:\psychopy 2021.2.3\lib\site-packages\psychopy\app\runner\”, line 689, in runLocal
File “D:\psychopy 2021.2.3\lib\site-packages\psychopy\scripts\”, line 74, in generateScript
compileScript(infile=exp, version=None, outfile=filename)
File “D:\psychopy 2021.2.3\lib\site-packages\psychopy\scripts\”, line 247, in compileScript
_makeTarget(thisExp, outfile, targetOutput)
File “D:\psychopy 2021.2.3\lib\site-packages\psychopy\scripts\”, line 226, in makeTarget
script = thisExp.writeScript(outfile, target=targetOutput)
File “D:\psychopy 2021.2.3\lib\site-packages\psychopy\”, line 232, in writeScript
File “D:\psychopy 2021.2.3\lib\site-packages\psychopy\experiment\”, line 235, in writeBody
File “D:\psychopy 2021.2.3\lib\site-packages\psychopy\experiment\”, line 404, in writeMainCode
File "D:\psychopy 2021.2.3\lib\site-packages\psychopy\experiment\components\keyboard_init
.py", line 248, in writeFrameCode
self.params[“name”], “Allowed keys list is invalid.”)
psychopy.experiment.utils.CodeGenerationException: resp_prac_final2:

I met such error when running the experiment. What should I do to deal with it?
Any responses are appreciated.

Try looking at the keyboard component called resp_prac_final2.

Make sure the field “Allowed Keys” is either empty or something like “left, right, a, b” depending which keys you want to monitor.

Hope this helps.

1 Like

Is there a backtick at the end of space?


Yes it really helps! Thank you very much!

Yes that’s the problem. I have added one. Thank you very much!