Appendix A — PsychoPy issues

If you have issues running an experiment, as a first step, it’s often a good idea to save your experiment, and then quit and restart PsychoPy. If the problem persists, try the suggestions below.

A.1 Checking your experiment

    • Are your image stimuli in the same folder as your experiment?
    • Is your input file in the same folder as your experiment?)
    • 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?
    • 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.

A.2 PsychoPy error messages

The error messages below appear in the Stdout section of the Runner:

The Stdout tab of the Runner window.

Angle brackets (<>) in the examples below are place-holders for variable or file names.

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

Possible underlying problems:

  • The variable name used in a component in PsychoPy does not match the variable name used in the conditions file.
  • 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.
  • A component is set to constant instead of set every repeat. For example:

A Text field using $stim combined with the setting 'constant'.

Error: KeyError: 'participant'

Underlying 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:

Experiment info with the 'Participant' field.

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

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

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

Underlying problem: PsychoPy cannot find the conditions file. The path and/or the file name might be incorrect.

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

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

Error: SyntaxError: invalid syntax

Underlying 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>

A.3 Getting help

  • Read the PsychoPy documentation.
  • Search the PsychoPy forum.
  • Search YouTube.
  • Search Google.
  • Consult Jon, Becca and Michael’s excellent PsychoPy book: Peirce, J., Hirst, R. & MacAskill, M. (2022). Building experiments in PsychoPy (2nd ed.). Sage Publications.