[solved] error: coercing to Unicode: need string or buffer, int found
I am getting this error message...I have no idea what is going on with this experiment. Anyone know what this could be?
An unexpected error occurred, which was not caught by OpenSesame. This should not happen! Message:
coercing to Unicode: need string or buffer, int found
Thanks
Comments
Hi Elizabeth,
Could you please post the full error message? You can find this in the debug window.
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
I get the same error message, so I figured I'll post it here and try to revive this thread.
Any help would be greatly appreciated because I'm basically stuck.
Here's the output from the debug window:
Hi,
This error is most likely due to the use of a non-numeric value to specify the Y coordinate of your text.
For example, the following line of script (in a
sketchpaditem) corresponds to drawing 'Some text' on the center of the screen:The second
0corresponds to the Y coordinate of the text. If you replace this by something that is not numeric, you will get an error. For example, the following script will trigger an error:This will also happen if specify the Y coordinate through a variable that has a non-numeric value. For example, the script below will work fine if
[my_var]is '0', but will give an exception if[my_var]is 'this_should_be_numeric'.Does this solve your problem?
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Yes, that's exactly what happened. Apparently, I accidentally deleted the Y coordinate and the next variable was non-numerical.
Thank you so much!
Hi there, I thought I would try to revive this thread because I am getting the same error message but I can not find a place in my program where there is a necessary integer that is missing. Here is an image of the debug window:

Hi,
What exactly are you trying to do? Could you also upload your experiment? The error message means that some of your variables are of type
integereven though they are supposed to bestringorunicode. But if you don't provide your code, it is difficult to point to the correct location.Eduard
Btw: maybe this discussion will help.
Hi I'm not sure how to upload my experiment because the file is too large even when compressed, though I'd be glad to send it directly if that's possible - I am trying to create a facial recognition test where there are 4 races and 2 genders within each represented. I have three sub loops - one for previously viewed faces the participant needs to identify, then sub loops for each of the 8 race/gender groupings, and one further loop within each of these sub loops that randomizes the position of the images on the sketchpad. I have been able to get a version of the program with just two race/gender sub loops to run but once the program runs one of these sub loops, it will not return to the largest loop and instead just continues to cycle through the sub loop, or more recently it will just end the experiment after a single trial and present this error message. Don't know if this info is helpful without the code - do you have any idea of how I might post it?
Ok, here is the debug window:
Python 2.7.12
Expyriment 0.8.0 (Python 2.7.12)
openexp.sampler._legacy.init_sound(): sampling freq = 48000, buffer size = 1024
experiment.run(): experiment started at Sun Dec 17 12:08:19 2017
experiment.run(): disabling garbage collection
experiment
experiment.end(): enabling garbage collection
Unexpected error
item-stack: experiment[run].Phase_3_2[run].P3_oldpics_2[run].newpics[run].LF_loop[run].LF_pos[run].xy_pos_LF[run].LF_trial[prepare].new_sketchpad_1[prepare]
exception type: TypeError
exception message: coercing to Unicode: need string or buffer, int found
time: Sun Dec 17 12:08:27 2017
Traceback:
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libqtopensesame/runners/inprocess_runner.py", line 38, in execute
self.experiment.run()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/experiment.py", line 411, in run
self.items.execute(self.var.start)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 91, in execute
self.run(name)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 106, in run
self[name].run()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/sequence.py", line 51, in run
self.experiment.items.run(_item)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 106, in run
self[name].run()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/sequence.py", line 51, in run
self.experiment.items.run(_item)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 106, in run
self[name].run()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/loop.py", line 338, in run
self.experiment.items.execute(self._item)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 91, in execute
self.run(name)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 106, in run
self[name].run()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/sequence.py", line 51, in run
self.experiment.items.run(_item)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 106, in run
self[name].run()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/loop.py", line 338, in run
self.experiment.items.execute(self._item)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 91, in execute
self.run(name)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 106, in run
self[name].run()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/sequence.py", line 51, in run
self.experiment.items.run(_item)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 106, in run
self[name].run()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/loop.py", line 338, in run
self.experiment.items.execute(self._item)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 90, in execute
self.prepare(name)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 122, in prepare
self[name].prepare()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/sequence.py", line 124, in prepare
self.experiment.items.prepare(_item)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 122, in prepare
self[name].prepare()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/sketchpad.py", line 118, in prepare
self.canvas.prepare()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/openexp/_canvas/xpyriment.py", line 97, in prepare
stim.plot(self._canvas)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/expyriment/stimuli/_visual.py", line 754, in plot
rect.center = [self.position[0] + stimulus_surface_size[0] / 2,
TypeError: coercing to Unicode: need string or buffer, int found
With regards to the linked forum post, I am unsure which variable it might be helpful to define in inline code outside of the loops, but also wouldn't defining a variable with an integer be the opposite of what the error is indicating needs to be done? There are no if statements in my code either, except the ones directing the main loop into the race/gender sub loops, and some reason I don't thing that those statements are the issue, though maybe the fact that the program can only run through trials of a single sub loop before breaking indicates that the if statements are where the problem is.
Hi,
Yes the problem is located somewhere in a sketchpad. You can upload your experiment anywhere, Googledocs, filedropper, etc. Perhaps, you can also simplify your experiment, i.e. remove some images from the filepool.
The stracktrace alone is not really enough to find out what is going on.
E