Problem Syncing with Pavlovia (Unable to create javascript)

First of all, thanks to everyone who responds to the forum. I have had to switch all of my experiments from in-person to online and this forum has been a great help. This is my first time posting, so please excuse any mistakes I make.

I have an experiment that works perfectly on my desktop (macOS) but fails to sync with pavlovia. I believe the issue occurs when psychopy tries to write the javascript for the experiment. From the traceback my guess is that the psychopy is having trouble with some code I added to select the conditionsFile

I used a code snippet to randomly assign participants to different conditions. In the conditionsFile, I used some ‘code’ I found on forums $‘inst_’+cond+’.xlsx’ to select the right excel file. This ‘code’ works in other experiments so I don’t think that is the issue. Below is the code snippet that starts the experiment and the Traceback.

Hopefully, I provided enough information. If it would help, I can upload the folder.

Here is the code snippet (in Begin Experiment).

The python version:
import random
cond = random.choice([‘control’,‘comp_orig’, ‘comp_scale’, ‘familiar’]) #Selects the condition
set = random.choice([“1”,“2”,“3”,“4”]) #selects the set
pos = random.sample([-0.5, 0.5], 2) #changes the position of the response options
pos_a = pos[0]
pos_r = pos[1]

The javascript version:
var shuffle = function (array) {

var currentIndex = array.length;
var temporaryValue, randomIndex;

// While there remain elements to shuffle...
while (0 !== currentIndex) {
    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;

    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
}

return array;

};
condition = [“control”,“comp_orig”, “comp_scale”, “familiar”][Math.floor(Math.random() * 4)];
set = [“1”,“2”,“3”,“4”][Math.floor(Math.random() * 4)];
pos = [-0.5, 0.5];
shuffle(pos);
pos_a = pos[0];
pos_r = pos[1];

Here is the traceback
Traceback (most recent call last):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 774, in findPathsInFile
File “”, line 1, in
NameError: name ‘cond’ is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/builder/builder.py”, line 1226, in onPavloviaSync
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/builder/builder.py”, line 719, in fileExport
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 73, in generateScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 242, in compileScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 214, in _makeTarget
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 212, in writeScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/flow.py”, line 290, in writeFlowSchedulerJS
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 821, in getResourceFiles
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 783, in findPathsInFile
FileNotFoundError: [Errno 2] No such file or directory: ‘/Users/balbirsingh/Documents/Pavlovia studies/zz 2020 JBTFam/JBT_Familiarity_Online.js’

I’ve just experienced the same error when attempting to sync to Pavlovia. I’m using the newest build of PsychoPy3, version 2020.2.3

I am also using the newest build version 2020.2.3. @jon could this be a bug?

Indeed it looks like it might be a bug in the way we’re searching for files ready to upload to the server. Could you help us track down when this occurs (I haven’t seen it in my own testing)? e.g.:

  • Does it just occur when using a particular output target (output folder in ExperiemtnSettings>Online is now set to be blank by default not html)
  • Does it occur only when using variables in conditions file names? I noticed you’ve got ‘cond’ in the file name here

If we can narrow it down a bit then @TParsons might be able to track down the issue

Thanks @jon for the prompt reply!
I set the output path to html and that seemed to help, but it did not fix the problem completely. After setting the output path to html the sync button worked. I looked in the html folder and psychophysics generated a java script.

However, my experiment does not work on pavlovia: Pavlovia.

It seems to be stuck at initializing the experiment. I am not sure if this is the same issue or something different.

@jon

I took a closer look and realized that the error was not identical to that reported above. My error occurred while attempting to compile the JS code for the experiment. Here is the traceback:

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 719, in fileExport
    target="PsychoJS")
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 73, in generateScript
    compileScript(infile=exp, version=None, outfile=filename)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 242, in compileScript
    _makeTarget(thisExp, outfile, targetOutput)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 214, in _makeTarget
    script = thisExp.writeScript(outfile, target=targetOutput, modular=True)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\_experiment.py", line 249, in writeScript
    self_copy._currentRoutine.writeEachFrameCodeJS(script, modular)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\routine.py", line 329, in writeEachFrameCodeJS
    comp.writeFrameCodeJS(buff)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 741, in writeFrameCodeJS
    self.writeParamUpdatesJS(buff, 'set every frame')
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 405, in writeParamUpdatesJS
    target="PsychoJS")
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 399, in writeParamUpdates
    target=target)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 435, in writeParamUpdate
    valStr = str(val).strip()
TypeError: __str__ returned non-string (type NoneType)

When I switched the version to an earlier one (v2020.1.3), it did not work. However, using v2020.2.2 I did manage to compile the script, but encountered this error when trying to sync.

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 1232, in onPavloviaSync
    retVal = pavlovia_ui.syncProject(parent=self, project=self.project)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\pavlovia_ui\project.py", line 512, in syncProject
    syncFrame.setStatus("Pushing files to Pavlovia")
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\runner\runner.py", line 878, in setStatus
    self.SetValue(status)
RuntimeError: wrapped C/C++ object of type StdOutText has been deleted

1 Like

@jon @TParsons

I believe both issues Jon identified are occurring. Adding html into the output file allowed the project to sync. However, I got an error saying ‘cond’ was not found. When I replaced the conditionsFile with one of the excel files in my folder the program started.

Now that the project is online, here is the gitlab repository:

Any help would be much appreciated.

That one is because you called the variable cond in Python but in the equivalent JS code you appear to have called it condition so cond indeed does not exist

@jon

Thank you, Now that the project is uploading to Pavlovia, I am going to close this thread. It seems that any trouble that I am having now are typos!

Hi @unagi_pie, have you solved the problem? I have the same error as you when trying to sync to Pavlovia, in version 2020.2.4.

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 1221, in onPavloviaSync
    self.fileExport(htmlPath=htmlPath)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 719, in fileExport
    target="PsychoJS")
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 73, in generateScript
    compileScript(infile=exp, version=None, outfile=filename)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 242, in compileScript
    _makeTarget(thisExp, outfile, targetOutput)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 214, in _makeTarget
    script = thisExp.writeScript(outfile, target=targetOutput, modular=True)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\_experiment.py", line 251, in writeScript
    self_copy._currentRoutine.writeRoutineBeginCodeJS(script, modular)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\routine.py", line 277, in writeRoutineBeginCodeJS
    thisCompon.writeRoutineStartCodeJS(buff)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 202, in writeRoutineStartCodeJS
    self.writeParamUpdatesJS(buff, 'set every repeat')
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 405, in writeParamUpdatesJS
    target="PsychoJS")
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 399, in writeParamUpdates
    target=target)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 435, in writeParamUpdate
    valStr = str(val).strip()
TypeError: __str__ returned non-string (type NoneType)

Hi,

I have a similar problem. Looks like it is failing when trying to export to html. I followed a simple builder tutorial here and made a demo experiment which works on my local, but fails when I try to move it online. When I exported to html from the file Menu, I get the same traceback error . Attaching the log below.

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 1221, in onPavloviaSync
    self.fileExport(htmlPath=htmlPath)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 719, in fileExport
    target="PsychoJS")
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 73, in generateScript
    compileScript(infile=exp, version=None, outfile=filename)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 242, in compileScript
    _makeTarget(thisExp, outfile, targetOutput)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 214, in _makeTarget
    script = thisExp.writeScript(outfile, target=targetOutput, modular=True)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\_experiment.py", line 251, in writeScript
    self_copy._currentRoutine.writeRoutineBeginCodeJS(script, modular)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\routine.py", line 277, in writeRoutineBeginCodeJS
    thisCompon.writeRoutineStartCodeJS(buff)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 202, in writeRoutineStartCodeJS
    self.writeParamUpdatesJS(buff, 'set every repeat')
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 405, in writeParamUpdatesJS
    target="PsychoJS")
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 399, in writeParamUpdates
    target=target)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\_base.py", line 435, in writeParamUpdate
    valStr = str(val).strip()
TypeError: __str__ returned non-string (type NoneType)

I have manually synced the files to gitlab. The traceback is also available in that folder. I’m using Psychopy 2020.2.4 on a windows10 machine

Update: When I remove the second loop, the project syncs online (but does not run - it gets stuck at initializing experiment).
This were the things in my second loop

  1. I used the same conditions file for both loops
  2. I was using a string concatenation in the text object of the second loop. ‘What color was ’ + $WordItem + ’ in the study phase?’ This was updating at every repeat (and the log indicates this is where the process is failing)
  3. I was not using the second parameter from the conditions file in the second loop at all.