Condition "group" assignment not pushing to Pavlovia

Description of the problem:
I am trying to get my working PsychoPy experiment uploaded to Pavlovia, but when I click “run the study online” it stays indefinitely in “synchronizing” until it becomes unresponsive. When I click “sync with web project” however, it provides an error:

“… line 898, in findPathsInFile
File “”, line 1, in
NameError: name ‘group’ is not defined”

First, is this the real reason it is never synchronizing to Pavlovia? If so, it seems to be having a problem with the fact that I have a code component creating a variable called “group” in order to run counterbalancing. This is that code component, which works fine in Psychopy:

I’ve also tried the make “group” by just generating a random number instead of pulling from the participant ID, which I thought was maybe the problem, but no luck there either on converting to pavlovia.

Any help would be greatly appreciated! Thanks!


As long as there is a JavaScript-error your experiment will not synchronize properly. Did you try to initialize the group-variable in a Begin-Experiment tab?

Best wishes Jens

Hi Jens, It is actually in the Begin-Routine tab of a code component in my very first slide (before the first loop begins where the conditions switch), and I just tried it in Begin-Experiment and got the same error. Thanks!

Put group=‘’ in Begin Experiment before your if statement

thanks for the suggestion, I just tried that with the same issue… here’s the two versions I’ve tried:

sorry, here’s the second

This looks fine. What error are you getting? Are you using Ctrl-Shift-R or an incognito tab to run the latest version?

This is the full error. It won’t push to pavlovia at all, so I am not on a browser, is that way you mean by incognito tab? This error happens when I click “synchronize” from psychopy and when I click “run the study online” is crashes psychopy.

I realized the same error also occurs when I try and compile it to javascript (but not python) so it’s definitely an issue with the javascript code

Hello Rachel,

is there a ; after the first line? The screenshot is cut off on the right side. So it is impossible to tell.

Best wishes Jens

there is in the group 2 example, but in group code the end of line 1 opens a bracket… I do not think the error is with the javascript code in this component, I have shown it to several people who know javascript and used chatgpt and made a few small suggested updates (% 2 == 0, for example)… but I am not sure what else it could be

I deleted and redownloaded psychopy and I can now get it to push to pavlovia, but it gets stuck on “initialising” which also appears to be the result of js code error. Thanks again for any insight

Hello Rachel,

You set the Code Type to both. The code you have written can be automatically translated by the Builder without any problems. Note that you initialise group but assign A and B to group2.

See below for an example that uses the auto-translation feature of the builder that also works in a browser.

In the Begin Experiment tab.

random_number = randint(1,3)

group2 = ''

if random_number % 2:
    group2 = 'A'
    group2 = 'B'

thisExp.addData("group2", group2)    

Best wishes Jens

1 Like

It is working now! thank you so much for your help!