Self-paced reading problem when Exporting HTML

Hi,
I’m new to PsychoPy (but do have programming experience with R), so please forgive me if this is a rookie error.

Description of the problem:

I am using PsychoPy 2020.2.10 with Windows 10.
I’ve written a self-paced reading script. I have two loops. The first loop, “trials”, chooses one of three .csv files (“ListA”, ListB", or “ListC”) representing three blocks. The choice of list is determined by pulling information from the Experiment Information (trialsFileName = ‘list’ + str(expInfo[‘list’]) + ‘.csv’). The second loop, “sentences”, pulls information from a column named “fileSelect” on the List_.csv file.

When I run it in builder it works perfectly.
However, when I try to Export HTML in order to run it in Pavlovia, I recieve the following error:

Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment_experiment.py”, line 808, in findPathsInFile
filePath = eval(filePath)
File “”, line 1, in
NameError: name ‘fileSelect’ is not defined

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 223, in writeScript
self_copy.flow.writeFlowSchedulerJS(script)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\flow.py”, line 289, in writeFlowSchedulerJS
resourceFiles = set([resource[‘rel’].replace("\", “/”) for resource in self.exp.getResourceFiles()])
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment_experiment.py”, line 856, in getResourceFiles
condsPaths = findPathsInFile(params[‘conditionsFile’].val)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment_experiment.py”, line 822, in findPathsInFile
files.extend(findPathsInFile(str(condFile)))
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment_experiment.py”, line 839, in findPathsInFile
conds = data.importConditions(thisFile[‘abs’]) # load the abs path
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\data\utils.py”, line 447, in importConditions
(fileName, len(trialList), len(fieldNames)))
UnboundLocalError: local variable ‘trialList’ referenced before assignment

I understand that the Conditions property that I have specified in the “sentences” loop ($fileSelect + ‘.csv’) has not been defined when it is initally called.
I had the same problem with the “trials” loop, but I solved it by adding code to the “Begin Experiment” tab on the first block of code at the begining of the experiment, which defined the Conditions for that loop (trialsFileName = ‘list’ + str(expInfo[‘list’]) + ‘.csv’).

I have spent time looking at many posts on this forum and have found similar problems, but none of the solutions have worked for me:

  • I have tried to define “fileSelect” at the begining of the experiment with a place holder, but it does not work.
  • I have checked to make sure that all of my code boxes are set to “Auto > JS”.
  • I have checked my .csv files to make sure there are no spaces.
  • I have removed the $ symbol from the Conditions box in the “sentences” loop properties. This enables a HTML script to be exported, but the experiment then crashes after the introduction when I run it in builder.
    I have exported the experiment to Pavlovia, but when I try to pilot the experiment it freezes at the “intializing the experiment” screen, which I presume is because of the same problem (i.e., no HTML).

I have attached the Python script and lastrun files.

Thank you very much in advance…

spr_test3_debug.py (31.1 KB)
spr_test3_debug_lastrun.py (31.1 KB)
spr_test3_debug.psyexp (40.0 KB)

The psyexp Builder file is the most useful file to share.

Freezing at the initialisation suggests a JavaScript error that should show up in the browser console. Have you checked? Often it’s due to someone trying to import a library.

Hi,

Thanks for the reply.
I have added the .psyexp file to the original message.
Here is the message from the browser control

Failed to load resource: the server responded with a status of 404 ()
/Nicklin/spr_test3_debug/spr_test3_debug.js:1
Failed to load resource: the server responded with a status of 404 ()
/favicon.ico:1

Please let me know if you need anything else…

UPDATE:
I rewrote the experiment from almost scratch, checking whether or not the builder version could run on pavlovia as I added each routine and component.
I now have the architecture of the experiment working exactly as I want!
If anyone in the future has similar problems to those listed in the OP, I recommend doing the same.