# Error when synchronizing experiment with Pavlovia

**URL:** <https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993>\
**Category:** Online experiments\
**Tags:** anaconda\
**Created:** [July 12, 2021, 11:08am UTC](https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993 "2021-07-12T11:08:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![elani](https://avatars.discourse-cdn.com/v4/letter/e/a8b319/32.png) [@elani](https://discourse.psychopy.org/u/elani)\
**Post date:** [July 12, 2021, 11:08am UTC](https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993/1 "2021-07-12T11:08:07Z")

</div>

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\experiment\_experiment.py”, 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!  
Elani

**Update:**  
Hi,  
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\experiment\_experiment.py”, 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\builder.py”, line 1320, in onPavloviaSync  
self.fileExport(htmlPath=htmlPath)  
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\app\builder\builder.py”, line 757, in fileExport  
self.generateScript(experimentPath=exportPath,  
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 73, in generateScript  
compileScript(infile=exp, version=None, outfile=filename)  
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 242, in compileScript  
\_makeTarget(thisExp, outfile, targetOutput)  
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 214, in \_makeTarget  
script = thisExp.writeScript(outfile, target=targetOutput, modular=True)  
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\experiment\_experiment.py”, line 229, in writeScript  
self\_copy.flow.writeFlowSchedulerJS(script)  
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\experiment\flow.py”, line 289, in writeFlowSchedulerJS  
resourceFiles = set([resource[‘rel’].replace("\", “/”) for resource in self.exp.getResourceFiles()])  
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\experiment\_experiment.py”, line 877, in getResourceFiles  
condsPaths = findPathsInFile(params[‘conditionsFile’].val)  
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\experiment\_experiment.py”, line 843, in findPathsInFile  
files.extend(findPathsInFile(str(condFile)))  
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\experiment\_experiment.py”, line 860, in findPathsInFile  
conds = data.importConditions(thisFile[‘abs’]) # load the abs path  
File “c:\users\eplog\anaconda3\lib\site-packages\psychopy\data\utils.py”, line 417, in importConditions  
fieldName = fieldNames[colN]  
IndexError: list index out of range

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [July 12, 2021, 12:02pm UTC](https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993/2 "2021-07-12T12:02:09Z")

</div>

Hello

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

---

<div class="post-metadata">

**Author:** ![elani](https://avatars.discourse-cdn.com/v4/letter/e/a8b319/32.png) [@elani](https://discourse.psychopy.org/u/elani)\
**Post date:** [July 12, 2021, 12:15pm UTC](https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993/3 "2021-07-12T12:15:42Z")

</div>

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

 ![expinfo](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/5/b5619d642037a2dedfd0cec38e773ef5eed742d5.png)

And maybe this helps, too. It is the loop with the csv file that depends on the group.  
 ![csv](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/8/4/849a3366b7fed870d6baf6358b74a6d8484a0232.png)

Thank you for your support

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [July 12, 2021, 1:07pm UTC](https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993/4 "2021-07-12T13:07:26Z")

</div>

Hello Elani

add a field called **participant**.

Best wishes Jens

---

<div class="post-metadata">

**Author:** ![elani](https://avatars.discourse-cdn.com/v4/letter/e/a8b319/32.png) [@elani](https://discourse.psychopy.org/u/elani)\
**Post date:** [July 12, 2021, 1:37pm UTC](https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993/5 "2021-07-12T13:37:51Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [July 12, 2021, 1:57pm UTC](https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993/6 "2021-07-12T13:57:29Z")

</div>

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?

`print(expInfo['Gruppe'])`

Can you access any value from expInfo?

BTW, if you want to try out an if-construction, it is  
` if int(expInfo['Gruppe']) == 1:`  
not  
`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

---

<div class="post-metadata">

**Author:** ![elani](https://avatars.discourse-cdn.com/v4/letter/e/a8b319/32.png) [@elani](https://discourse.psychopy.org/u/elani)\
**Post date:** [July 12, 2021, 2:34pm UTC](https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993/7 "2021-07-12T14:34:13Z")

</div>

Hi,

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

```auto
# 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:

```auto
# set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(nReps=1.0, method='sequential', 
    extraInfo=expInfo, originPath=-1,
    trialList=data.importConditions('group'+expInfo['group']+'.csv'),
    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

---

<div class="post-metadata">

**Author:** ![elani](https://avatars.discourse-cdn.com/v4/letter/e/a8b319/32.png) [@elani](https://discourse.psychopy.org/u/elani)\
**Post date:** [July 12, 2021, 4:42pm UTC](https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993/8 "2021-07-12T16:42:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [July 13, 2021, 9:26am UTC](https://discourse.psychopy.org/t/error-when-synchronizing-experiment-with-pavlovia/23993/9 "2021-07-13T09:26:57Z")

</div>

Hello Elani

that are great news. Good luck with your experiment.

Best wishes Jens
