| Reference | Downloads | Github

Converting PsychoPy Script from Version 2 of Python to Version 3

I am currently trying to get a PsychoPy script which was originally created with the old PsychoPy 2 to work with PsychoPy 3.

I’ve been tasked with getting this working, and I’m not a psychologist, just the local computer guy. Hence I’m trying to fix the code rather than re-invent in builder.

The code launches as expected, requests a participant number, then errors:

Traceback (most recent call last):
  File "C:\Users\class3\Desktop\", line 92, in <module>
    exec(paramName + '= thisTrial.' + paramName)
  File "\<string\>", line 1, in <module>
AttributeError: 'collections.OrderedDict' object has no attribute 'PRIME'

Looking at the definition for PRIME, I find this function:

Prime = visual.TextStim(win=win, ori=0, name='Prime',
    text=u'prime',    font=u'Arial',
    pos=[0, 0], height=0.1, wrapWidth=None,
    color=u'white', colorSpace='rgb', opacity=1,

visual.TextStim is deprecated, but I assume it should still work.

Any guidance would be very gratefully received, whether it is why the PRIME function isn’t working, or what I should replace it with.



Python is case sensitive, so you need to searching the script for PRIME rather than Prime.

Having said that, has that error message been copied and pasted verbatim and in full? Because File "\<string\>", line 1, in <module> also looks a little suspect.


From that tiny code snippet, it looks like Builder-generated Python anyway. So is there an associated .psyexp file that could be worked with? If it can be opened in Builder, that would save you a lot of hassle, as it would generate the Python 3 .py file for you automatically.