psychopy.org | Reference | Downloads | Github

Error exporting HTML files

Hi everyone

OS: Win10
PsychoPy version: PsychoPy 3.0.5
Standard Standalone? : Yes. Using the Builder.
What are you trying to achieve?: I have an experiment in which I present shapes and participants have to react to them. I am trying to export this to HTML to run it online. When running in PsychoPy, it doesn’t crash. I have used to Builder to create the experiment.

What did you try to make it work?: After reading previous posts, I made sure that I had git installed. I also tried to export the experiment without a code component (written both in Python and Java), just to make sure it wasn’t because of that.

**What specifically went wrong when you tried that?: I get the following error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 1682, in fileExport
    target="PsychoJS")
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 2237, in generateScript
    def _getHtmlPath(self, filename):
  File "C:\Program Files (x86)\PsychoPy3\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "C:\Program Files (x86)\PsychoPy3\lib\subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['C:\\Program Files (x86)\\PsychoPy3\\pythonw.exe', '-m', 'psychopy.scripts.psyexpCompile', 'H:\\Behavioral\\IdeoInst\\Online\\ObservAct\\ObservAct.psyexp', '-o', 'H:\\Behavioral\\IdeoInst\\Online\\ObservAct\\html\\ObservAct.js', '-v', 'latest']' returned non-zero exit status 120.

Any help is much appreciated!

Hi, try switching your version in Experiment Settings from ‘latest’ to 3.0.5. I suggest this because that line in my standalone relates to version parameters and I also get a logging error when using ‘latest’.

Thanks @dvbridges! that got rid of the error!

I have two further questions:

  1. For randomization purposes, I have a couple of .csv files with different trial lists. At the beginning of my experiment, I randomly pick one of these .csv files with a code component (written both in Python and Java). Here’s the java snippet:
// Begin Experiment

function random_character() {
    var chars = "ABCD";
    return chars.substr( Math.floor(Math.random() * 2), 1);
}

condition = random_character();

Then, in the “condition” box of my main routine, I load the corresponding .csv file:

'design_' + $condition + '.csv'

When running in PsychoPy, this works fine. However, when I try to export, I get the following error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 1682, in fileExport
    target="PsychoJS")
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 2242, in generateScript
    else:
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 51, in compileScript
    script = thisExp.writeScript(outfile, target=targetOutput, modular=True)
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\_experiment.py", line 201, in writeScript
    self.settings.writeInitCodeJS(script, self.psychopyVersion, localDateTime, modular)
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\components\settings\__init__.py", line 497, in writeInitCodeJS
    self.prepareResourcesJS()
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\components\settings\__init__.py", line 486, in prepareResourcesJS
    resourceFiles = self.exp.getResourceFiles()
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\_experiment.py", line 790, in getResourceFiles
    condsPaths = findPathsInFile(params['conditionsFile'].val)
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\_experiment.py", line 743, in findPathsInFile
    filePath = eval(filePath)
  File "<string>", line 1
    'Block_' + $condition + '.csv'
               ^
SyntaxError: invalid syntax

I get that the way of calling the condition variable is not working, but, any ideas on how to properly call it?

  1. If my .psyexp file is in a different drive from C:, then I get the following error when trying to import to html (the experiment runs in psychopy smoothly):
Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 1682, in fileExport
    target="PsychoJS")
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 2242, in generateScript
    else:
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py", line 51, in compileScript
    script = thisExp.writeScript(outfile, target=targetOutput, modular=True)
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\_experiment.py", line 201, in writeScript
    self.settings.writeInitCodeJS(script, self.psychopyVersion, localDateTime, modular)
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\components\settings\__init__.py", line 497, in writeInitCodeJS
    self.prepareResourcesJS()
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\components\settings\__init__.py", line 486, in prepareResourcesJS
    resourceFiles = self.exp.getResourceFiles()
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\_experiment.py", line 801, in getResourceFiles
    thisFile = getPaths(thisParam.val)
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\_experiment.py", line 722, in getPaths
    thisFile['rel'] = os.path.relpath(filePath, srcRoot)
  File "C:\Program Files (x86)\PsychoPy3\lib\ntpath.py", line 586, in relpath
    path_drive, start_drive))
ValueError: path is on mount 'C:', start on mount 'H:'

If I copy the folder of the experiment to C:, then I can convert to html just fine, but I was wondering if it would be possible to convert from different drives…

Thanks!

Great, I have added a GitHub issue to get this fixed for next release.

The first new error is because the dollar sign needs to start at the beginning of the line. It tells PsychoPy that this is a line of code, not that it is a variable that needs evaluating. So use:

$'Block_' + condition + '.csv'

Hmm not come across this error before, trying to output the html to a different drive. We could raise an issue on GitHub for this one.

thanks @dvbridges! that again solved the problem

1 Like