Howdy, Stranger!

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

Supported by

'int' object has no attribute error: why am I getting it now?

Hi all,

I am trying to modify an experiment in OpenSesame that was working fine. In the process of modifying the experiment, I started getting different version of the same error, 'int' object has no attribute 'X'. For example:

Error while executing inline script

item-stack: experiment[run].Set_Stage_ACQ1[run]
exception type: AttributeError
exception message: 'int' object has no attribute 'Stage'
item: Set_Stage_ACQ1
time: Sat Sep 29 17:18:52 2018
phase: run

Traceback:
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\inline_script.py", line 96, in run
self.experiment.python_workspace._exec(self.crun)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\base_python_workspace.py", line 124, in _exec
exec(bytecode, self._globals)
Inline script, line 1, in
AttributeError: 'int' object has no attribute 'Stage'

Here is the inline script code causing the error (in the run tab):

var.Stage = "ACQ1"
var.Stage_Trial = 0

Earlier in the experiment, the following inline script causes no error:

var.Stage = "PRACQ"
var.Stage_Trial = 0

Also, in the original experiment neither inline script causes an error.

I get the error with both the psychopy and expyriment backends.

I have attached the original experiment that works (fear_conditioning_FINAL) and the new one that is having the errors (counter_conditioning_Test1.3)--again, both have the same inline script.

System information:
System: Windows-10-10.0.16299
Architecture: win64
OpenSesame 3.2.5

Thanks for any advice you have! I greatly appreciate this community and OpenSesame!

-- Tom

Comments

  • Hi Tom,

    I have a hard time reproducing the error. Just from reading the code, there shouldn't be a problem.
    Could you provide a minimal example that leads to the same problem? I.e. remove as much as possible from your experiment without making the error disappear.

    Thanks,

    Eduard

    Thanked by 1TomArmstrong
  • Thanks for the reply, Eduard. I removed the unnecessary items before the sequence in which the error occurs, and I now get a different error. When I removed fewer items, I got the same error (below), but with a different stimulus from the file pool. In both cases, I can see the stimulus that failed to load in the file pool. I have attached the file.

    Stopped

    The experiment did not finish normally for the following reason:

    Unexpected error
    Details

    item-stack: experiment[run].PRACQ[run].PRACQ_sequ[prepare].CS[prepare]
    exception type: IOError
    exception message: Found file 'c:\users\armstrtr\appdata\local\temp\tmp23ra3q.opensesame_pool\face1.jpg' [= c:\users\armstrtr\appdata\local\temp\tmp23ra3q.opensesame_pool\face1.jpg], failed to load as an image
    time: Tue Oct 02 08:54:03 2018
    Traceback (also in debug window)

    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libqtopensesame\misc\process.py", line 157, in run
    exp.run()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\experiment.py", line 456, in run
    self.items.execute(self.var.start)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 103, in execute
    self.run(name)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
    self[name].run()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sequence.py", line 51, in run
    self.experiment.items.run(_item)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
    self[name].run()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\loop.py", line 347, in run
    self.experiment.items.execute(self._item)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 102, in execute
    self.prepare(name)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 142, in prepare
    self[name].prepare()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sequence.py", line 124, in prepare
    self.experiment.items.prepare(_item)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 142, in prepare
    self[name].prepare()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sketchpad.py", line 149, in prepare
    temp_name, element.element_name
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\openexp_canvas\canvas.py", line 354, in exit
    self.prepare()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\openexp_canvas\canvas.py", line 775, in prepare
    element.prepare()
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\openexp_canvas_image\psycho.py", line 33, in prepare
    image=safe_decode(self.fname)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\psychopy\visual\image.py", line 97, in init
    self.setImage(image, log=False)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\psychopy\visual\image.py", line 289, in setImage
    setAttribute(self, 'image', value, log)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\psychopy\tools\attributetools.py", line 137, in setAttribute
    setattr(self, attrib, value)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\psychopy\tools\attributetools.py", line 27, in set
    newValue = self.func(obj, value)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\psychopy\visual\image.py", line 276, in image
    forcePOW2=False)
    File "C:\Program Files (x86)\OpenSesame\lib\site-packages\psychopy\visual\basevisual.py", line 803, in _createTexture
    raise IOError, msg % (tex, os.path.abspath(tex))
    IOError: Found file 'c:\users\armstrtr\appdata\local\temp\tmp23ra3q.opensesame_pool\face1.jpg' [= c:\users\armstrtr\appdata\local\temp\tmp23ra3q.opensesame_pool\face1.jpg], failed to load as an image

  • I decided to go back and start from scratch with the original experiment file that I was modifying, and now things are working fine. Thanks for trying to look into this Edward. No need to bother with it anymore, unless it might reveal a bug worth fixing....

  • edited October 3
    Hi Tom,

    I haven't looked at the experiment, but based on the (first) error message, it seems like a clear case of 'shadowing'.

    That is, somewhere in the experiment, an integer is assigned to `var` (e.g. `var = 10`), so that `var` is no longer the original `var` object, and hence has no properties. Does that make sense?

    Cheers!
    Sebastiaan
    Thanked by 1TomArmstrong

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • Thanks, Sebastiaan. That makes perfect sense and explains other errors that were occurring!

Sign In or Register to comment.