Experiment not working on Pavlovia: variable is not iterable (cannot read property undefined)

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Windows
PsychoPy version (e.g. 2024.2.4 Py 3.8): 20251.1
Standard Standalone Installation? (y/n) y
URL of experiment:

Do you want it to also run locally? y
What are you trying to achieve?:

My experiment works fine locally, but when I try to run it on Pavlovia I get the following error:

BlurStartSAMPLE is not iterable (cannot read property undefined)

This is a variable in my Trials.xlsx file, and used in the code component in the Stimulus routine.

What did you try to make it work?:

I have been trying lots of things today with various different problems occurring when trying to run the experiment on Pavlovia.

I have tried pushing the experiment from an older version of PsychoPy but then I get different problems.

It would be fantastic if someone could take a look at my experiment for me.

Link to the most relevant existing thread you have found:

What specifically went wrong when you tried that?:
My experiment does not contain an element like what was described in the previous post.

Your experiment current has platform 3.2 which I’m guessing means that you’ve pushed it with a pre 2020 version. Please start by using a more recent version.

Although I couldn’t open your psyexp file I did spot <Param name="Begin Routine" updates="constant" val="ImageSample = Image_SAMPLE + str(int(BlurStartSAMPLE)) + &quot;.jpg&quot;&amp;#10;" valType="extendedCode"/> which suggests that you have a text component set to constant which should update each routine.

BlurInvert.psyexp (74.3 KB)

Thank you so much for your quick response! Indeed I had uploaded with an older version because I was receiving a different error message when I tried to push with the 2025 1.1 version. When I try to push it I get this error:

“Traceback (most recent call last):

File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\app\builder\builder.py”, line 1621, in onPavloviaSync

pavlovia_ui.syncProject(parent=self, file=self.filename, project=self.project)

File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\app\pavlovia_ui\project.py”, line 854, in syncProject

project.sync()

File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\projects\pavlovia.py”, line 916, in sync

self.firstPush(infoStream=infoStream)

File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\projects\pavlovia.py”, line 1155, in firstPush

info = self.commit(

File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\projects\pavlovia.py”, line 1321, in commit

info = self.repo.git.commit('-m', message)

File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\git\cmd.py”, line 986, in

return lambda \*args, \*\*kwargs: self.\_call_process(name, \*args, \*\*kwargs)

File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\git\cmd.py”, line 1599, in _call_process

return self.execute(call, \*\*exec_kwargs)

File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\git\cmd.py”, line 1389, in execute

raise GitCommandError(redacted_command, status, stderr_value, stdout_value)

git.exc.GitCommandError: Cmd(‘C:\Users\u789160\AppData\Local\Programs\PsychoPy\MinGit\cmd\git.exe’) failed due to: exit code(1)

cmdline: C:\Users\u789160\AppData\Local\Programs\PsychoPy\MinGit\cmd\git.exe commit -m Push initial project files

stdout: 'On branch master

nothing to commit, working tree clean’“

I uninstalled and reinstalled Psychopy but I still get this same error message.

The ImageSample code I have is used to change the image with each loop, and as far as I can tell it is set to “set every repeat“. I have added the psyexp file here so hopefully you can open it now.

Do you have an idea what’s going wrong?

Thanks again!

I think that “nothing to commit, working tree clean” means it couldn’t generate JS files.

I think that the reason for that is your function code in End Routine.

I recommend that you define functions in Before Experiment in the format:

Python

def function1(x): 
    if x == 31:
        x = 30
    elif x == 1:
        x = 2
    return(x)


JavaScript

function function1(x) {
    if (x === 31) {
        x = 30;
    } else if (x === 1) {
        x = 2;
    }
    return x;
}

Secondly, BlurStartSAMPLE is in your Excel file so don’t change its value in the code.

Hello again,

After a weekend break, I understand what you suggested. Now I have tried to define the functions before the experiment, but they don’t seem to work now. I see that the experiment is recording my keyboard response, but that doesn’t lead to a change in blur level like it used to.

Do you have time to take a look again at my changes?

Thanks,

Laura

Trials.xlsx (17.5 KB)

BlurInvert.psyexp (74.2 KB)

Another update. I have the function working again and the variable from my Excel file no longer updates during the experiment. But I’m still unable to push the experiment to Pavlovia.

BlurInvert.psyexp (73.9 KB)

If you add me as a developer to the repository and unprotect your master branch I could try to sync it for you (Settings / Repository / Protected Branches in Gitlab).

Thank you. I think I have done it now!

Somehow I managed to push to Pavlovia now, but the experiment is still not running:

Hi,

You’ve set the project to public. Please could you add me as a developer?

It looks like you have html as the output folder.

You should be added now.

I didn’t have html as output earlier. It was something I changed recently in an attempt to fix the problem

Ok. Please could you now switch it to inactive and back to piloting (only the owner can do this)?

Done!

Now it runs and gives the error

{“origin”:“WindowMixin._getLengthPix”,“context”:“when converting a length from stimulus unit to pixel units”,“error”:“unable to deal with unit: degFlat”}

Units must be height, norm or pixels to work online.

Thank you. I changed the units to height, in a new experiment called “BlurInvert_height“ but it still won’t push and gives the error below:

Traceback (most recent call last):
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\git\cmd.py”, line 1262, in execute
proc = safer_popen(
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\git\cmd.py”, line 281, in _safer_popen_windows
return Popen(
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\subprocess.py”, line 971, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\subprocess.py”, line 1456, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 206] De bestandsnaam of -extensie is te lang

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\app\builder\builder.py”, line 1621, in onPavloviaSync
pavlovia_ui.syncProject(parent=self, file=self.filename, project=self.project)
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\app\pavlovia_ui\project.py”, line 854, in syncProject
project.sync()
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\projects\pavlovia.py”, line 916, in sync
self.firstPush(infoStream=infoStream)
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\projects\pavlovia.py”, line 1154, in firstPush
self.stageFiles(infoStream=infoStream)
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\projects\pavlovia.py”, line 1303, in stageFiles
self.repo.git.add(diffsDict[‘untracked’])
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\git\cmd.py”, line 986, in
return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\git\cmd.py”, line 1599, in _call_process
return self.execute(call, **exec_kwargs)
File “C:\Users\u789160\AppData\Local\Programs\PsychoPy\lib\site-packages\git\cmd.py”, line 1276, in execute
raise GitCommandNotFound(redacted_command, err) from err
git.exc.GitCommandNotFound: Cmd(‘C:\Users\u789160\AppData\Local\Programs\PsychoPy\MinGit\cmd\git.exe’) not found due to: FileNotFoundError(‘[WinError 206] De bestandsnaam of -extensie is te lang’)
cmdline: C:\Users\u789160\AppData\Local\Programs\PsychoPy\MinGit\cmd\git.exe add BlurInvert_height-legacy-browsers.js BlurInvert_height.js BlurInvert_height.psyexp

error message continues listing all the image files

Each folder online can only have one experiment file.

In the new version that I tried, there is only one experiment file in the folder. Nothing is on GitHub because it wouldn’t synchronize.

Can you edit and sync the one I helped with?

No I can’t get it to sync from PsychoPy. When I try it says a folder exists with that name already so I need to use a different name. Is there a way to sync that doesn’t go via Pavlovia?

Thanks. I just tried this. But after editing the experiment file (to use height), it wouldn’t sync again. I created a new simple experiment to test and that did sync with Pavlovia so it’s something specific to this experiment. Could it be due to the large number of images I have?