| Reference | Downloads | Github

Error when synchronizing experiment with Pavlovia

Hi @JensBoelte ,

while your solution works perfektly within the builder, I have a problem when I try to synchronize it with Pavlovia…

I get the following error:
Traceback (most recent call last):
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\”, line 829, in findPathsInFile
filePath = eval(filePath)
File “”, line 1, in
NameError: name ‘expInfo’ is not defined

As soon as I remove the conditions line ($‘group’+expInfo[‘Gruppe’]+’.csv’), the synchronization works again… Do you have an idea what to do about it?

Thanks again for your help!

thanks again for the quick reply. I tried it again after adding the csv files under Experiement Settings - Online - additional resources, but I still have the problem…

This is the complete error that occurs:
Traceback (most recent call last):
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\”, line 829, in findPathsInFile
filePath = eval(filePath)
File “”, line 1, in
NameError: name ‘expInfo’ is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\app\builder\”, line 1320, in onPavloviaSync
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\app\builder\”, line 757, in fileExport
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\scripts\”, line 73, in generateScript
compileScript(infile=exp, version=None, outfile=filename)
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\scripts\”, line 242, in compileScript
_makeTarget(thisExp, outfile, targetOutput)
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\scripts\”, line 214, in _makeTarget
script = thisExp.writeScript(outfile, target=targetOutput, modular=True)
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\”, line 229, in writeScript
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\experiment\”, line 289, in writeFlowSchedulerJS
resourceFiles = set([resource[‘rel’].replace("\", “/”) for resource in self.exp.getResourceFiles()])
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\”, line 877, in getResourceFiles
condsPaths = findPathsInFile(params[‘conditionsFile’].val)
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\”, line 843, in findPathsInFile
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\”, line 860, in findPathsInFile
conds = data.importConditions(thisFile[‘abs’]) # load the abs path
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\data\”, line 417, in importConditions
fieldName = fieldNames[colN]
IndexError: list index out of range

Thank you for your help!


it worked for my on-line and off-line. Sorry, that is doesn’t work out for you. So, there is some else wrong. How do you specify your expInfo-dialog?

Best wishes Jens

that’s really weird…
This is the experiment setting window, including the experiment info:

And maybe this helps, too. It is the loop with the csv file that depends on the group.

Thank you for your support

Hello Elani

add a field called participant.

Best wishes Jens

Hi Jens,

I added a field called participant, but it is still not working… It again says expInfo is not defined
As soon I change the $‘group’+expInfo[‘Gruppe’]+’.csv’ part in the conditions to, e.g., group1.csv there is no problem…
Do you think it makes sense to add a code component at some point, giving a specific description for each group (e.g., if expInfo[‘Gruppe’] == 1: condition = group1.csv, and then switch the condition in loop saying $condition, or something like this?)
and add this variable in the csv file name?
When you think this might work, where should I add the code component so that the condtion variable is saved throughout the experiment (sorry for these basic questions, this is my first psychopy experience)

Thank you for being patient :slight_smile:

Hello Elani,

yes, you add some code to select the proper group. But I am afraid that something is wrong with your expInfo-dialog. Can you simply print some values to the log?


Can you access any value from expInfo?

BTW, if you want to try out an if-construction, it is
if int(expInfo['Gruppe']) == 1:
if expInfo['Gruppe'] == 1:

I asked you to add a field called participant because that is used in the result file-name and deleting it from the expInfo-dialog does not delete it from the result file-name.

Best wishes Jens


printing anything doesn’t work…
it still says not defined…
Within the Python code this part looks like this (I changed everything to english now… thought this might help in some way, but of course it didn’t):

# Store info about the experiment session
psychopyVersion = '2021.1.4'
expName = 'SAMs_alllearning phases'  # from the Builder filename that created this script
expInfo = {'participant': '', 'session': '', 'group': ''}
dlg = gui.DlgFromDict(dictionary=expInfo, sortKeys=False, title=expName)
if dlg.OK == False:
    core.quit()  # user pressed cancel
expInfo['date'] = data.getDateStr()  # add a simple timestamp
expInfo['expName'] = expName
expInfo['psychopyVersion'] = psychopyVersion

and the csv part within the trials like this:

# set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(nReps=1.0, method='sequential', 
    extraInfo=expInfo, originPath=-1,
    seed=None, name='trials')
thisExp.addLoop(trials)  # add the loop to the experiment
thisTrial = trials.trialList[0]  # so we can initialise stimuli with some values
# abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
if thisTrial != None:
    for paramName in thisTrial:
        exec('{} = thisTrial[paramName]'.format(paramName))

Maybe this helps…
Generating the JS Code doesn’t work either… I get the same error (expInfo is not defined)…

Best regards

Hi Jens,

I still don’t know what went wrong, but I just copied and pasted each routine into a new experiment and tried to upload it again. This finally worked! I think I messed something up when I changed the ExpInfo at some point but I am just glad that it is working now!

Thanks again for all your help,
really love this forum!

Best wishes

Hello Elani

that are great news. Good luck with your experiment.

Best wishes Jens