H PsychoPy issues

As a first step, it might be a good idea to save your experiment, and then quit and restart PsychoPy. If the problem persists, try the suggestions below.

H.1 Checking your experiment

  • If you are running a recent version of macOS, have you made sure to tick “Input Monitoring”? (see Section ??)
  • Are the paths correct? (Are your image stimuli in the same folder as your experiment? Is your input file in the same folder as your experiment?)
  • Are the file names correct? Perhaps your picture is called myPic.jpg, but PsychoPy is looking for myPic.jpeg? Perhaps your input file is called Conditions.xlsx and PsychoPy is looking for conditions.xlsx?
  • Have you chosen a sensible size/letter height and unit for displaying stimuli?
    • Using “norm” or “height” and 0.1 is fine, using “pix” and 0.1 will be invisible.
    • Using “pix” and 150 is fine, using “norm” or “height” and 150 will stop your experiment from running.
  • Have you selected “set every repeat” for things that change from trial to trial?
  • Have you added the $ sign before your variable names in PsychoPy?
  • Do your variable names in PsychoPy match those in your Excel input file? (E.g., $colour in PsychoPy, but header “Colour” in Excel.)
  • Have you made sure there are no spaces in your Excel input file (e.g., after the variable names in your header row, after your response keys or after any file names)?
  • Are your key names lower case (in your input file and in your keyboard component)?
  • It can help to make multiple copies of the experiment and remove one routine in each copy to help you work out which routine it is that stops the experiment from running. Once you know that, you can have a closer look at this particular routine. (And you could then try to remove individual components from this routine.)
  • In general, make sure to change only one thing at a time when trying to isolate the cause underlying a problem (it is like designing an experiment; if you change multiple things at a time, you will no longer know what is causing an effect).
  • Set up simplified versions of the experiment that only focus on the one thing that is not working.
  • Compare your experiment to experiments that work.

H.2 PsychoPy error messages

The error messages below appear in the Stdout section of the Runner assuming the experiment was started from the Runner (see Section 21.5.2). Angle brackets (<>) in the examples below are place-holders for variable or file names.

Error: NameError: name '<variable_name>' is not defined

Problem 1: The variable name used in a component in PsychoPy does not match the variable name used in the conditions file.

Problem 2: The variable name in a code component does not match the name of the component to which it refers. For example, a code component says resp.corr, but the Keyboard component is named key_resp.

Problem 3: A component is set to constant instead of set every repeat. For example:

Error: KeyError: 'participant'

Problem: PsychoPy insists on the field participant (not capitalised!) in the Experiment Settings if the default name for the output file is used. This will not work:


psychopy.exceptions.ConditionsImportError: Conditions file <file_name>: Parameters (column headers) cannot contain punctuation or spaces
"<variable_name_in_header> "

Problem: There is a space after one of the column headers in the input file.

Error: ValueError: Conditions file not found: <file_name>

Problem: PsychoPy cannot find the conditions file. A frequent reason for this error is that the conditions file was added to a loop before the experiment was saved. If the conditions file was indeed added before the experiment was saved, the “Conditions” field looks like this:

Error: OSError: Couldn't find image <file_name>; check path?

Problem: PsychoPy cannot find an image it is looking for. The path and/or the file name might be incorrect.

Error: SyntaxError: invalid syntax

Problem: There is probably an issue with a Code component. Check the error message for additional details. For example the tab and line number:

  • Python Syntax Error in 'Begin Routine' tab.
  • on line number <x>

H.3 Getting help

  • Read the PsychoPy documentation.
  • Search the PsychoPy forum.
  • Search YouTube.
  • Search Google.
  • Consult Jon and Michael’s excellent PsychoPy book: Peirce, J., & MacAskill, M. (2022). Building experiments in PsychoPy (2nd ed.). Sage Publications.
  • Have a look at the demos that come with PsychoPy: In PsychoPy’s menu bar: Click on DemosUnpack Demos → choose location where to unpack demos and unpack → click on Demos in the menu bar again → there should now be a list of demo experiments