psychopy.org | Reference | Downloads | Github

Bug in 1.85.3b - crashes with only default rating scale


#1

Possibly related to Stimulus display error crashing an experiment

I downloaded 1.85.3b today and it crashed a task that previously worked. I narrowed it down to a ratings scale. I made a new task that contains only a ratings scale with the default options and it crashes with the following error message (same message as my crashing task):

########### Running: /Users/alexmillner/Desktop/untitled_lastrun.py ############
2017-08-30 18:38:17.643 python[3500:4434636] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/t5/rkll1mvs3mzgf2t3r7xgnhtw0000gn/T/org.psychopy.PsychoPy2.savedState
Traceback (most recent call last):
File “/Users/alexmillner/Desktop/untitled_lastrun.py”, line 117, in
win.flip()
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/window.py”, line 655, in flip
thisStim.draw()
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/ratingscale.py”, line 1140, in draw
mouseX, mouseY = self.myMouse.getPos() # norm units
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/event.py”, line 558, in getPos
lastPosPix = lastPosPix - self.win.size / 2
TypeError: unsupported operand type(s) for /: ‘tuple’ and 'int’
Exception RuntimeError: RuntimeError(‘sys.meta_path must be a list of import hooks’,) in <bound method ExperimentHandler.del of <psychopy.data.experiment.ExperimentHandler object at 0x113a8b6d0>> ignored


#2

I’ve been helping Alex and duplicated this on my own dev laptop - both with MacOS 10.12.6 and 1.85.3b Mac OS App.


#3

I ran into the same problem too, and here’s the solution. You’ll see the error message below:

File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/event.py”, line 558, in getPos
lastPosPix = lastPosPix - self.win.size / 2
TypeError: unsupported operand type(s) for /: ‘tuple’ and ‘int’

Click on the boldfaced text and event.py will open, and you’ll be at line 558 (see below). Line 558 is trying to divide the tuple self.win.size by 2, which is the line that’s causing the error. You can try in your shell: (1, 2) / 2 or [1, 2] / 2, and you’ll get the same error message (unsupported operand type) because you can’t divide tuples or lists by a number.

To solve the problem, just turn self.win.size into a numpy array, and comment out the original line (558). See line two below for solution. Hope that helps!

# lastPosPix = lastPosPix - self.win.size / 2 # line 558
lastPosPix =  lastPosPix - numpy.array(self.win.size) / 2 # working version