psychopy.org | Reference | Downloads | Github

Demo Mental Rotation not working with py3

Dear all,
I’m using some demos to teach Perception to my psychology students. I translated the Stroop task and it worked beautifully, but I’m having problems with Mental Rotation. Data are collected but I don’t get the plot at the end of the experiment.
I get the following error warning:

Traceback (most recent call last):
File “/Users/olgasoler/Documents/PsychoPy3 Demos/mental_rotation/MentalRot_lastrun.py”, line 690, in
fd.write(data_string)
TypeError: a bytes-like object is required, not ‘str’

I am a complete ignorant on python coding and I would be immensely grateful if any of you can give me a hint on how to correct this.

Thanks a lot in advance,
Olga

Hi @olgasoler, thanks for letting us know about the bug. To fix, you will need to go into the code component of the “plot_data” routine, and change two lines of code. Go to the “Begin Routine” tab in the code component, and change:

with open(filename, 'wb') as fd:

to

with open(filename, 'w') as fd:

Then, at the bottom of the code, change:

with open(filename, 'a+b') as fd:

to

with open(filename, 'a') as fd:

This should fix your problem and return your plots and performance data

Thank you David @dvbridges ! This indeed solved the problem :slight_smile:
You have been most helpful!
Olga