TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

OS: Mac 10.15.3
PsychoPy version: 3
Standard Standalone? (y/n) If not then what?:
**What are you trying to achieve?: Visual cueing experiment

I have a png that I manage to get to switch orientations using an Excel file on a loop. Then I add an ISI and somewhere along the line I get this error. Once I have the error, it seems to persist whatever I do. I don’t have any of my own code in the experiment, it’s all just Psychopy.

Red_Arrow_Pointing_Right.setOri(Orientation)
File “/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/visual/basevisual.py”, line 1379, in setOri
setAttribute(self, ‘ori’, newOri, log, operation)
File “/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/tools/attributetools.py”, line 141, in setAttribute
setattr(self, attrib, value)
File “/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/tools/attributetools.py”, line 32, in set
newValue = self.func(obj, value)
File “/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/visual/basevisual.py”, line 1255, in ori
radians = value * 0.017453292519943295
TypeError: unsupported operand type(s) for *: ‘NoneType’ and ‘float’

Thanks

Dan

Somehow your Orientation variable is getting set to None rather than containing a number. Firstly check your conditions file for any blank cells.

Otherwise, try inserting a code component and at relevant points (e.g. in the “begin routine” tab), put something like:

print(Orientation)

to see what the current value is, and if it meets what you think it should be.

1 Like

Thank you so much Michael

I have a similar error showing in my experiment. And I have no clue about the reason. Hope you can help me with it.

Traceback (most recent call last):
  File "F:\GNG\Go-Nogo_lastrun.py", line 537, in <module>
    win.flip()
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\window.py", line 910, in flip
    thisStim.draw()
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\text.py", line 775, in draw
    self.rgb, self.colorSpace, self.contrast)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\basevisual.py", line 439, in _getDesiredRGB
    rgb = rgb / 127.5 - 1
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

Try printing the current value of rgb just before you rescale it.

1 Like