Hello everyone,
I am a beginner in both Python and PsychoPy, so any detailed guidance would be greatly appreciated.
I’m experiencing an issue while running the “EyeLinkPicture_Builder” demo provided by SR Research in PsychoPy Builder. Below are the details of the problem:
Problem Description:
I encountered the following error message when trying to run the demo file:
File "S:\eyelink_devKit\EyeLink\SampleExperiments\Python\examples\Psychopy_examples\Builder\EyeLinkPicture_Builder\EyeLinkPicture_Builder_lastrun.py", line 1808, in <module>
run(
File "S:\eyelink_devKit\EyeLink\SampleExperiments\Python\examples\Psychopy_examples\Builder\EyeLinkPicture_Builder\EyeLinkPicture_Builder_lastrun.py", line 667, in run
el_tracker.sendCommand(el_coords)
UnboundLocalError: local variable 'el_tracker' referenced before assignment
################ Experiment ended with exit code 1 [pid:29300] #################
PsychoPy Version: 2024.1.5
Operating System: Windows 11
Steps Taken:
- I have ensured that all necessary files and dependencies are in place.
- I have checked the script to see if
el_tracker
is properly initialized before being used.
To address the issue of validating file names, I made the following changes before encountering the el_tracker
error:
#loop until we get a valid filename
while True:
dlg = gui.Dlg(dlg_title)
dlg.addText(dlg_prompt)
dlg.addField('File Name:', edf_fname)
# show dialog and wait for OK or Cancel
ok_data = dlg.show()
if dlg.OK: # if ok_data is not None
print('EDF data filename: {}'.format(ok_data['File Name:']))
else:
print('user cancelled')
core.quit()
sys.exit()
# get the string entered by the experimenter
tmp_str = dlg.data['File Name:']
# strip trailing characters, ignore the ".edf" extension
edf_fname = tmp_str.rstrip().split('.')[0]
# check if the filename is valid (length <= 8 & no special char)
allowed_char = ascii_letters + digits + '_'
if not all([c in allowed_char for c in edf_fname]):
print('ERROR: Invalid EDF filename')
elif len(edf_fname) > 8:
print('ERROR: EDF filename should not exceed 8 characters')
else:
break
Specifically, I changed ok_data[0]
to ok_data['File Name:']
and tmp_str = dlg.data[0]
to tmp_str = dlg.data['File Name:']
. Despite these changes, the error persists.
Any help or guidance on how to fix this error would be greatly appreciated. Thank you!