psychopy.org | Reference | Downloads | Github

PsychoPy experiment doesn't load

I made a new experiment using the Builder view, but when I try to load it, it fails and I get the following error message

Failed to load C:\Users\adrian\Insync\Work\Projects\SoL\Pic viewing 1.psyexp. Please send the following to the PsychoPy user list
Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\builder.py", line 1473, in fileOpen
    self.exp.loadFromXML(filename)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\experiment.py", line 596, in loadFromXML
    self.flow.append(self.routines[elementNode.get('name')])
KeyError: 'trial'
Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\builder.py", line 1634, in OnFileHistory
    self.fileOpen(filename=path)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\builder.py", line 1485, in fileOpen
    self.updateAllViews()  # if frozen effect will be visible on thaw
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\builder.py", line 1718, in updateAllViews
    self.flowPanel.draw()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\flow.py", line 644, in draw
    thisTerm = self.loops[thisLoop]['term']
KeyError: 'term'

I’m using the latest version of PsychoPy on Windows 10.

Adrian

Edit - very limited investigation suggests it might be something to do with trying to preload an image during an ISI period. Possibly an avenue for investigation?

One way to corrupt an experiment file is certainly to set a stimulus to update during a static period (e.g. ISI) and then delete that static period. I’m not sure if that’s what you’ve done though. Could you post the experiment file so we can take a look, but also post any hints about what you did before the problem started happening? The error message is complaining about a missing object “trial” and a missing object “term” so it’s probably related to those objects/variables

cheers

I don’t ‘think’ I created and then deleted a static period (but I might be wrong). Although, I might have deleted/modified the default ‘trial’ routine that might have contained a static period. I’m also displaying a fixation cross during the static period (but it’s onset and offset are not within the static period). I don’t remember naming anything ‘term’ though. I’ve uploaded the troublesome psyexp file.

Thanks for your help with this,

AdrianPic viewing 1.psyexp (12.2 KB)

OK, here’s your fixed experiment:
Pic viewing 1.psyexp (12.2 KB)

I believe you found a new way to break the static period, by renaming a routine that contained one. We’ll have to add that to the list of static component errors.

But the fix was actually easy when you know how: your experiment was complaining that it couldn’t find the ‘trial’ routine so I opened the experiment in a text editor and removed the line where it tried to use the ‘trial’. Then the experiment would load again, just with a gap in your flow where the ‘trial’ had been.

Thanks for the help!

I’m pleased my incompetence has proved at least slightly useful for once.

I had a similar issue yesterday (just as I was about to demonstrate a practical prototype to a lecturer :-S) - it looks like when routines are renamed they are not removed from the namespace immediately (for instance, if you rename a trial called trial as trial, the routine is named trial_2.

Interestingly been getting some weird flow errors too - for instance in the replication below all the flow representations have vanished but the experiment still works…

Might need to add this to general issues

We think this was caused by renaming a Routine; this was a new feature and apparently not working correctly as of 1.84.1. The bug that led to this issue is now fixed and will be included in next release (1.84.2).

For anyone else having this issue you can fix your file manually like this (make a copy of your experiment first in case you really mess it up!):

  • open your .psyexp file in a text editor (e.g. notepad+ on windows, textwrangler on mac)
  • near the bottom of the file you’ll see a section describing the Flow
  • find the line referring to the Routine name that you changed (no longer exists) and simply change it to the name you changed it to (exactly, with matching capitals)
  • For example, if you changed the trial routine to be called presentPics then you find/need to change the like this:
  • <Routine name="trial"/> :arrow_right: <Routine name="presentPics"/>

If you can’t make that work then post a copy of your experiment here for us to change for you (folks you can “unwatch” this thread if you don’t want updates!)

Hi Jon

I dont think we changed any of the routine names. Here is the file below:

beTaskedit.psyexp (21.4 KB)

If I replace
<Routine name="response_2"/>
with
<Routine name="confidence_2"/>
the experiment works, and confidence_2 was otherwise not on the Flow, so I’ve got a strong suspicion there was a “rename” performed at some stage :wink:

Which is fine - you did the right thing - it’s just that we had a bug in the renaming.

If I’m right then this is fixed:
beTaskedit.psyexp (21.4 KB)

I was having a similar problem, but wasn’t able to figure out the solution. I have attached my psychoPy experiment here if anyone wants to take a look and help me out. Thank you in advance.

MentalRotation.psyexp (50.7 KB)

As explained in the rest of this thread, these errors are coming about from Routines that have been renamed and they can be fixed in a text editor.

In your case you created a routine called InsterStimInt and then renamed it to InterStimInt so you needed to find the line that said
<Routine name="InsterStimInt"/>
and replace it with
<Routine name="InterStimInt"/>

MentalRotation.psyexp (50.7 KB)

Thanks Jon… Very helpful as always!!! Hope you are well. :slight_smile:

1 Like

Hi!

We have the same problems with our experiment :frowning:
We get the following error message:

  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\builder.py", line 1718, in updateAllViews
    self.flowPanel.draw()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\app\builder\flow.py", line 644, in draw
    thisTerm = self.loops[thisLoop]['term']
KeyError: 'term'

This is the experiment file:
TatataSuono.psyexp (66.8 KB)

Thank you for your help!!

Martina

Hi Martina - the solution to this is detailed above (see the post with the green tick) and the underlying issue has been resolved as of 1.84.2.
BW

Oli

Also, in the new release (1.84.2) I’ve set it to at least load the experiment when this has gone wrong and all you’ll need to do is re-insert any missing Routines (ones that have been renamed) back into your Flow.

I am running into this same bug with version 3.05 (Mac 10.13.6). Further, when I open my experiment, no flow appears in the builder. When I try to run the experiment anyways, it does not result in an error either-it just exits out of the experiment before it can start and returns me back to the builder. I know it has to do with the fact that I renamed ISI and sound components. Therefore, I have been looking really closely through the file in a Text Editor to see if there is a mismatch among component names. Unfortunately, I cannot find anything that is misnamed (I may have not seen something). The only thing I see is that the “flow” segment of the code is missing in the text editor file. It does not show any information pertaining to the flow of the experiment.

I have attached a screenshot of the builder without the flow diagram and have uploaded my experiment (the experiment is a second version as i have already created a copy in accordance with your suggestion above). I really appreciate your help!

TestP3B1MR_v2.psyexp (27.6 KB)