currently I am creating an experiment in Psychopy. Now I have included two code components which contain variables I use for counting.
I define these as integer 0 under ‘Begin experiment’:
japvStimper = 0 nojapvStimper = 0 chosen_text2 = 0 noStimper2 = 0 audioStimper2 = 0 chosen_sound2 = 0
Then I programmed ‘if conditions’ because two variables should vary. The variables that are supposed to vary half/half are japvStim and nojapvStim. The conditions file has 10 rows in total, thus neither of my variables should be picked more than 5 times.
# choose one of the two variables: chosen_text2 = np.random.choice([japvStim, nojapvStim]) if japvStimper < 5 and chosen_text2 == japvStim: japvStimper = japvStimper + 1 else: chosen_text2 = nojapvStim if nojapvStimper < 5 and chosen_text2 == nojapvStim: nojapvStimper += 1 else: chosen_text2 = japvStim japvStimper += 1
When I try to run my experiment now, I get this error:
File “/Users/reinhard/Desktop/Experiment/myexp4_lastrun.py”, line 78
Traceback (most recent call last):
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/builder/builder.py”, line 2022, in onProcessEnded
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/stdOutRich.py”, line 134, in write
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/app/stdOutRich.py”, line 62, in write
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/wx/_core.py”, line 13092, in WriteText
return core.TextEntryBase_WriteText(*args, **kwargs)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xef in position 4: ordinal not in range(128)
It seems like I only get this error once I include the two code components above and my conditions.xlsx for my actual test items. Everything worked fine before, even when I used my training items together with the two code components above (only 4 rows, different conditions spreadsheet).
How can I fix the Unicode error? I tried using an older version, Psychopy 1.85.2 to no avail.
Or do I need to convert my variables to integer? I can’t see where this error related to strings occurs… (I’m rather new to Python, so I am rather a layman, please be gentle ).
Thank you very much in advance!