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’