Unkown error with experiment: Alert 4405

I have been programming different sessions for an experiment using the builder. I had to remove the info dialog and create a routine for participants to input their participant ID with and explanation of what to use. This has worked fine for all of the other files I have done this on but has resulting in only the first two routines running and the following output. I am not sure what the issue is as I have three other files of different conditions that are working fine with the only difference being the excel files they pull from.

Any help would be greatly appreciated :slight_smile:

Output from runner

Alert 4405: Editable textbox component textbox and keyboard component enter in the same routine may compete for keypresses
For more info see https://docs.psychopy.org/alerts/4405.html####### Running: C:\Program Files\PsychoPy\LST\Eng_00\Eng_00_lastrun.py ########
2057.5719 INFO Loaded monitor calibration from [‘2021_11_25 14:59’]
C:\Program Files\PsychoPy\lib\site-packages\numpy_distributor_init.py:30: UserWarning: loaded more than 1 DLL from .libs:
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
C:\Program Files\PsychoPy\lib\site-packages\numpy.libs\libopenblas.PYQHXLVVQ7VESDPUVUADXEVJOBGHJPAY.gfortran-win_amd64.dll
C:\Program Files\PsychoPy\lib\site-packages\numpy.libs\libopenblas.XWYDX2IKJW2NMTWSFYNGFUWKQU3LYTCZ.gfortran-win_amd64.dll
warnings.warn(“loaded more than 1 DLL from .libs:”
C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\shape.py:251: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
Hello from the pygame community. Contribute - pygame wiki
3.6714 WARNING We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use [‘sounddevice’, ‘PTB’, ‘pyo’, ‘pygame’] (in that order).
C:\Program Files\PsychoPy\lib\site-packages\numpy_distributor_init.py:30: UserWarning: loaded more than 1 DLL from .libs:
C:\Program Files\PsychoPy\lib\site-packages\numpy.libs\libopenblas.PYQHXLVVQ7VESDPUVUADXEVJOBGHJPAY.gfortran-win_amd64.dll
C:\Program Files\PsychoPy\lib\site-packages\numpy.libs\libopenblas.XWYDX2IKJW2NMTWSFYNGFUWKQU3LYTCZ.gfortran-win_amd64.dll
warnings.warn(“loaded more than 1 DLL from .libs:”
1.8231 WARNING Monitor specification not found. Creating a temporary one…
ioHub Server Process Completed With Code: 0
if value == “circle”:
################# Experiment ended with exit code 0 [pid:3460] #################
Failed to load C:\Program Files\PsychoPy\LST\Eng_00\Eng_00.psyexp. Please send the following to the PsychoPy user list
Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\runner\runner.py”, line 1009, in loadExperiment
exp.loadFromXML(fileName)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment_experiment.py”, line 752, in loadFromXML
param.val = eval(‘%s’ % (param.val))
File “”, line 1, in
NameError: name ‘datetime’ is not defined
2086.9674 INFO Loaded monitor calibration from [‘2021_11_25 14:59’]

the lastrun.py script:

#!/usr/bin/env python

-- coding: utf-8 --

“”"
This experiment was created using PsychoPy3 Experiment Builder (v2022.2.5),
on July 21, 2023, at 11:10
If you publish work using this script the most relevant publication is:

Peirce J, Gray JR, Simpson S, MacAskill M, Höchenberger R, Sogo H, Kastman E, Lindeløv JK. (2019) 
    PsychoPy2: Experiments in behavior made easy Behav Res 51: 195. 
    https://doi.org/10.3758/s13428-018-01193-y

“”"

— Import packages —

from psychopy import locale_setup
from psychopy import prefs
from psychopy import sound, gui, visual, core, data, event, logging, clock, colors, layout
from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED,
STOPPED, FINISHED, PRESSED, RELEASED, FOREVER)

import numpy as np # whole numpy lib is available, prepend ‘np.’
from numpy import (sin, cos, tan, log, log10, pi, average,
sqrt, std, deg2rad, rad2deg, linspace, asarray)
from numpy.random import random, randint, normal, shuffle, choice as randchoice
import os # handy system and path functions
import sys # to get file system encoding

import psychopy.iohub as io
from psychopy.hardware import keyboard

Ensure that relative paths start from the same directory as this script

_thisDir = os.path.dirname(os.path.abspath(file))
os.chdir(_thisDir)

Store info about the experiment session

psychopyVersion = ‘2022.2.5’
expName = ‘Eng_00’ # from the Builder filename that created this script
expInfo = {
‘participant’: ‘’,
‘session’: ‘’,
}
expInfo[‘date’] = data.getDateStr() # add a simple timestamp
expInfo[‘expName’] = expName
expInfo[‘psychopyVersion’] = psychopyVersion

Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc

filename = thisDir + os.sep + u’data/%s%s_%s’ % (expInfo[‘participant’], expName, expInfo[‘date’])

An ExperimentHandler isn’t essential but helps with data saving

thisExp = data.ExperimentHandler(name=expName, version=‘’,
extraInfo=expInfo, runtimeInfo=None,
originPath=‘C:\Program Files\PsychoPy\LST\Eng_00\Eng_00_lastrun.py’,
savePickle=True, saveWideText=True,
dataFileName=filename)

save a log file for detail verbose info

logFile = logging.LogFile(filename+‘.log’, level=logging.EXP)
logging.console.setLevel(logging.WARNING) # this outputs to the screen, not a file

endExpNow = False # flag for ‘escape’ or other condition => quit the exp
frameTolerance = 0.001 # how close to onset before ‘same’ frame

Start Code - component code to be run after the window creation

— Setup the Window —

win = visual.Window(
size=[1280, 720], fullscr=True, screen=0,
winType=‘pyglet’, allowStencil=False,
monitor=‘testMonitor’, color=[0.0000, 0.0000, 0.0000], colorSpace=‘rgb’,
blendMode=‘avg’, useFBO=True,
units=‘height’)
win.mouseVisible = False

store frame rate of monitor if we can measure it

expInfo[‘frameRate’] = win.getActualFrameRate()
if expInfo[‘frameRate’] != None:
frameDur = 1.0 / round(expInfo[‘frameRate’])
else:
frameDur = 1.0 / 60.0 # could not measure, so guess

— Setup input devices —

ioConfig = {}

Setup iohub keyboard

ioConfig[‘Keyboard’] = dict(use_keymap=‘psychopy’)

ioSession = ‘1’
if ‘session’ in expInfo:
ioSession = str(expInfo[‘session’])
ioServer = io.launchHubServer(window=win, **ioConfig)
eyetracker = None

create a default keyboard (e.g. to check for escape)

defaultKeyboard = keyboard.Keyboard(backend=‘iohub’)

— Initialize components for Routine “Participant_id” —

Title = visual.TextStim(win=win, name=‘Title’,
text=‘Participant ID\n’,
font=‘Open Sans’,
pos=(0, 0.35), height=0.05, wrapWidth=None, ori=0.0,
color=‘white’, colorSpace=‘rgb’, opacity=None,
languageStyle=‘LTR’,
depth=0.0);
main_body = visual.TextStim(win=win, name=‘main_body’,
text=‘Please enter the first letter of your first name, the first letter of your last name, and the last four digits of your phone number, for example JP5678 for Jack Pott 0712345678’,
font=‘Open Sans’,
pos=(0, 0.2), height=0.04, wrapWidth=None, ori=0.0,
color=‘white’, colorSpace=‘rgb’, opacity=None,
languageStyle=‘LTR’,
depth=-1.0);
textbox = visual.TextBox2(
win, text=None, font=‘Open Sans’,
pos=(0, 0), letterHeight=0.05,
size=(None, None), borderWidth=2.0,
color=‘darkslateblue’, colorSpace=‘rgb’,
opacity=None,
bold=False, italic=False,
lineSpacing=1.0,
padding=0.0, alignment=‘center’,
anchor=‘center’,
fillColor=None, borderColor=None,
flipHoriz=False, flipVert=False, languageStyle=‘LTR’,
editable=True,
name=‘textbox’,
autoLog=True,
)
enter = keyboard.Keyboard()
text_6 = visual.TextStim(win=win, name=‘text_6’,
text=‘Press Space to continue’,
font=‘Open Sans’,
pos=(0, -0.2), height=0.04, wrapWidth=None, ori=0.0,
color=‘white’, colorSpace=‘rgb’, opacity=None,
languageStyle=‘LTR’,
depth=-4.0);

— Initialize components for Routine “Instructions” —

spce_end = keyboard.Keyboard()
instructions_txt = visual.TextStim(win=win, name=‘instructions_txt’,
text=‘Welcome to the experiment.\n\nYou will see 48 sleep related descriptions about an imaginary character ‘Anna’. Please read each description and answer questions relating to your assumptions on Anna’s level of tiredness and stress by clicking your answer in the scale from 1-5. There are not right or wrong answers – we just want to know what you think.\n\nThe descriptions and questions follow the same pattern, which makes it relatively quick for you to read thorough the 48 descriptions and answer the questions. We anticipate completing the experiment will take about 10 minutes.\n\nPlease press the space bar to see the first description. \n’,
font=‘Open Sans’,
pos=(0, 0), height=0.035, wrapWidth=None, ori=0.0,
color=‘white’, colorSpace=‘rgb’, opacity=None,
languageStyle=‘LTR’,
depth=-1.0);

Create some handy timers

globalClock = core.Clock() # to track the time since experiment started
routineTimer = core.Clock() # to track time remaining of each (possibly non-slip) routine

— Prepare to start Routine “Participant_id” —

continueRoutine = True
routineForceEnded = False

update component parameters for each repeat

textbox.reset()
enter.keys =
enter.rt =
_enter_allKeys =

keep track of which components have finished

Participant_idComponents = [Title, main_body, textbox, enter, text_6]
for thisComponent in Participant_idComponents:
thisComponent.tStart = None
thisComponent.tStop = None
thisComponent.tStartRefresh = None
thisComponent.tStopRefresh = None
if hasattr(thisComponent, ‘status’):
thisComponent.status = NOT_STARTED

reset timers

t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock=“now”)
frameN = -1

— Run Routine “Participant_id” —

while continueRoutine:
# get current time
t = routineTimer.getTime()
tThisFlip = win.getFutureFlipTime(clock=routineTimer)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame

# *Title* updates
if Title.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
    # keep track of start time/frame for later
    Title.frameNStart = frameN  # exact frame index
    Title.tStart = t  # local t and not account for scr refresh
    Title.tStartRefresh = tThisFlipGlobal  # on global time
    win.timeOnFlip(Title, 'tStartRefresh')  # time at next scr refresh
    # add timestamp to datafile
    thisExp.timestampOnFlip(win, 'Title.started')
    Title.setAutoDraw(True)

# *main_body* updates
if main_body.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
    # keep track of start time/frame for later
    main_body.frameNStart = frameN  # exact frame index
    main_body.tStart = t  # local t and not account for scr refresh
    main_body.tStartRefresh = tThisFlipGlobal  # on global time
    win.timeOnFlip(main_body, 'tStartRefresh')  # time at next scr refresh
    # add timestamp to datafile
    thisExp.timestampOnFlip(win, 'main_body.started')
    main_body.setAutoDraw(True)

# *textbox* updates
if textbox.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
    # keep track of start time/frame for later
    textbox.frameNStart = frameN  # exact frame index
    textbox.tStart = t  # local t and not account for scr refresh
    textbox.tStartRefresh = tThisFlipGlobal  # on global time
    win.timeOnFlip(textbox, 'tStartRefresh')  # time at next scr refresh
    # add timestamp to datafile
    thisExp.timestampOnFlip(win, 'textbox.started')
    textbox.setAutoDraw(True)

# *enter* updates
waitOnFlip = False
if enter.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
    # keep track of start time/frame for later
    enter.frameNStart = frameN  # exact frame index
    enter.tStart = t  # local t and not account for scr refresh
    enter.tStartRefresh = tThisFlipGlobal  # on global time
    win.timeOnFlip(enter, 'tStartRefresh')  # time at next scr refresh
    # add timestamp to datafile
    thisExp.timestampOnFlip(win, 'enter.started')
    enter.status = STARTED
    # keyboard checking is just starting
    waitOnFlip = True
    win.callOnFlip(enter.clock.reset)  # t=0 on next screen flip
    win.callOnFlip(enter.clearEvents, eventType='keyboard')  # clear events on next screen flip
if enter.status == STARTED and not waitOnFlip:
    theseKeys = enter.getKeys(keyList=['space'], waitRelease=False)
    _enter_allKeys.extend(theseKeys)
    if len(_enter_allKeys):
        enter.keys = _enter_allKeys[-1].name  # just the last key pressed
        enter.rt = _enter_allKeys[-1].rt
        # a response ends the routine
        continueRoutine = False

# *text_6* updates
if text_6.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
    # keep track of start time/frame for later
    text_6.frameNStart = frameN  # exact frame index
    text_6.tStart = t  # local t and not account for scr refresh
    text_6.tStartRefresh = tThisFlipGlobal  # on global time
    win.timeOnFlip(text_6, 'tStartRefresh')  # time at next scr refresh
    # add timestamp to datafile
    thisExp.timestampOnFlip(win, 'text_6.started')
    text_6.setAutoDraw(True)

# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
    core.quit()

# check if all components have finished
if not continueRoutine:  # a component has requested a forced-end of Routine
    routineForceEnded = True
    break
continueRoutine = False  # will revert to True if at least one component still running
for thisComponent in Participant_idComponents:
    if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
        continueRoutine = True
        break  # at least one component has not yet finished

# refresh the screen
if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
    win.flip()

— Ending Routine “Participant_id” —

for thisComponent in Participant_idComponents:
if hasattr(thisComponent, “setAutoDraw”):
thisComponent.setAutoDraw(False)
thisExp.addData(‘textbox.text’,textbox.text)

check responses

if enter.keys in [‘’, , None]: # No response was made
enter.keys = None
thisExp.addData(‘enter.keys’,enter.keys)
if enter.keys != None: # we had a response
thisExp.addData(‘enter.rt’, enter.rt)
thisExp.nextEntry()

the Routine “Participant_id” was not non-slip safe, so reset the non-slip timer

routineTimer.reset()

— Prepare to start Routine “Instructions” —

continueRoutine = True
routineForceEnded = False

update component parameters for each repeat

spce_end.keys =
spce_end.rt =
_spce_end_allKeys =

keep track of which components have finished

InstructionsComponents = [spce_end, instructions_txt]
for thisComponent in InstructionsComponents:
thisComponent.tStart = None
thisComponent.tStop = None
thisComponent.tStartRefresh = None
thisComponent.tStopRefresh = None
if hasattr(thisComponent, ‘status’):
thisComponent.status = NOT_STARTED

reset timers

t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock=“now”)
frameN = -1

— Run Routine “Instructions” —

while continueRoutine:
# get current time
t = routineTimer.getTime()
tThisFlip = win.getFutureFlipTime(clock=routineTimer)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame

# *spce_end* updates
waitOnFlip = False
if spce_end.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
    # keep track of start time/frame for later
    spce_end.frameNStart = frameN  # exact frame index
    spce_end.tStart = t  # local t and not account for scr refresh
    spce_end.tStartRefresh = tThisFlipGlobal  # on global time
    win.timeOnFlip(spce_end, 'tStartRefresh')  # time at next scr refresh
    # add timestamp to datafile
    thisExp.timestampOnFlip(win, 'spce_end.started')
    spce_end.status = STARTED
    # keyboard checking is just starting
    waitOnFlip = True
    win.callOnFlip(spce_end.clock.reset)  # t=0 on next screen flip
    win.callOnFlip(spce_end.clearEvents, eventType='keyboard')  # clear events on next screen flip
if spce_end.status == STARTED and not waitOnFlip:
    theseKeys = spce_end.getKeys(keyList=['space'], waitRelease=False)
    _spce_end_allKeys.extend(theseKeys)
    if len(_spce_end_allKeys):
        spce_end.keys = _spce_end_allKeys[-1].name  # just the last key pressed
        spce_end.rt = _spce_end_allKeys[-1].rt
        # a response ends the routine
        continueRoutine = False

# *instructions_txt* updates
if instructions_txt.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
    # keep track of start time/frame for later
    instructions_txt.frameNStart = frameN  # exact frame index
    instructions_txt.tStart = t  # local t and not account for scr refresh
    instructions_txt.tStartRefresh = tThisFlipGlobal  # on global time
    win.timeOnFlip(instructions_txt, 'tStartRefresh')  # time at next scr refresh
    # add timestamp to datafile
    thisExp.timestampOnFlip(win, 'instructions_txt.started')
    instructions_txt.setAutoDraw(True)

# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
    core.quit()

# check if all components have finished
if not continueRoutine:  # a component has requested a forced-end of Routine
    routineForceEnded = True
    break
continueRoutine = False  # will revert to True if at least one component still running
for thisComponent in InstructionsComponents:
    if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
        continueRoutine = True
        break  # at least one component has not yet finished

# refresh the screen
if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
    win.flip()

— Ending Routine “Instructions” —

for thisComponent in InstructionsComponents:
if hasattr(thisComponent, “setAutoDraw”):
thisComponent.setAutoDraw(False)

check responses

if spce_end.keys in [‘’, , None]: # No response was made
spce_end.keys = None
thisExp.addData(‘spce_end.keys’,spce_end.keys)
if spce_end.keys != None: # we had a response
thisExp.addData(‘spce_end.rt’, spce_end.rt)
thisExp.nextEntry()

the Routine “Instructions” was not non-slip safe, so reset the non-slip timer

routineTimer.reset()

— End experiment —

Flip one final time so any remaining win.callOnFlip()

and win.timeOnFlip() tasks get executed before quitting

win.flip()

these shouldn’t be strictly necessary (should auto-save)

thisExp.saveAsWideText(filename+‘.csv’, delim=‘auto’)
thisExp.saveAsPickle(filename)
logging.flush()

make sure everything is closed down

if eyetracker:
eyetracker.setConnectionState(False)
thisExp.abort() # or data files will save again on exit
win.close()
core.quit()