Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Keep getting KeyError: u''

Hello! I'm trying to setup my self paced word training sequence, but I keep getting a keyerror with the following error message:

Error while executing inline script

item-stack: experiment[run].training_2[run].nonword_sequence_2[prepare].nonword_disp_2[prepare]
exception type: KeyError
exception message: u''
item: nonword_disp_2
time: Mon Mar 25 12:05:01 2019
phase: prepare

  File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 77, in prepare
  File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 124, in _exec
    exec(bytecode, self._globals)
  Inline script, line 2, in <module>
KeyError: u''

My nonword_disp_2 inline script is as follows:

#mapped with wordorder variable in loop table.
var.set('nonword_2', wordmap_2[var.get('wordorder')])

I thought that it was an issue with my nonword lists not having the unicode prefix, but even after I prefixed them with u, I keep getting this error. I am only getting this keyerror with my second lexicon (nonwords_2/wordmap_2), but not my first lexicon (nonwords_1/wordmap_1). I have attached the relevant part of my exp as well as the spreadsheets that are my loop tables.


  • When does the error occur? I just tried ~50 trials for each loop and I can't reproduce the error.

    You could also try to load the excel file in an inline_script and check whether each word was read correctly.

    import pandas as pd
    df = pd.read_excel(filename)


    Thanked by 1peapodpeapod
  • Hi Eduard,

    Turns out it was an error with my excel spreadsheet! Thanks for your help.

Sign In or Register to comment.