psychopy.org | Reference | Downloads | Github

Unhandled internal error: SyntaxError: invalid syntax

Clicking File > Export HTML, I get the unhandled internal error popup with:

Traceback (most recent call last):
  File "/home/arnon/temp/MAD/psychopy4/lib64/python3.6/site-packages/psychopy/app/builder/builder.py", line 719, in fileExport
    target="PsychoJS")
  File "/home/arnon/temp/MAD/psychopy4/lib64/python3.6/site-packages/psychopy/scripts/psyexpCompile.py", line 73, in generateScript
    compileScript(infile=exp, version=None, outfile=filename)
  File "/home/arnon/temp/MAD/psychopy4/lib64/python3.6/site-packages/psychopy/scripts/psyexpCompile.py", line 242, in compileScript
    _makeTarget(thisExp, outfile, targetOutput)
  File "/home/arnon/temp/MAD/psychopy4/lib64/python3.6/site-packages/psychopy/scripts/psyexpCompile.py", line 214, in _makeTarget
    script = thisExp.writeScript(outfile, target=targetOutput, modular=True)
  File "/home/arnon/temp/MAD/psychopy4/lib64/python3.6/site-packages/psychopy/experiment/_experiment.py", line 212, in writeScript
    localDateTime, modular)
  File "/home/arnon/temp/MAD/psychopy4/lib64/python3.6/site-packages/psychopy/experiment/components/settings/__init__.py", line 527, in writeInitCodeJS
    self.prepareResourcesJS()
  File "/home/arnon/temp/MAD/psychopy4/lib64/python3.6/site-packages/psychopy/experiment/components/settings/__init__.py", line 515, in prepareResourcesJS
    resourceFiles = self.exp.getResourceFiles()
  File "/home/arnon/temp/MAD/psychopy4/lib64/python3.6/site-packages/psychopy/experiment/_experiment.py", line 830, in getResourceFiles
    condsPaths = findPathsInFile(params['conditionsFile'].val)
  File "/home/arnon/temp/MAD/psychopy4/lib64/python3.6/site-packages/psychopy/experiment/_experiment.py", line 818, in findPathsInFile
    for thisFile in findPathsInFile(val):
  File "/home/arnon/temp/MAD/psychopy4/lib64/python3.6/site-packages/psychopy/experiment/_experiment.py", line 782, in findPathsInFile
    filePath = eval(filePath)
  File "<string>", line 1
    Now that you have completed the practice trials, you can begin the actual task! There will be two blocks, each lasting between 8-10 minutes. You will have an opportunity to take a short break in-between the blocks. Feel free to rest and stretch if necessary.
           ^
SyntaxError: invalid syntax

This experiment compiles and runs fine in 2020.1.2.
In 2020.2.3, I get the issue described here.
The error above is from 2020.2.4.

The experiment I am trying to compile can be found here: https://gitlab.pavlovia.org/MAD_LAB/incentivized-flanker-w-perceptual-load

If I understand the error message correctly, PsychoPy is looking for potential resource file paths in a spreadsheet file (blocks.xlsx), and is bombing on a cell containing plain text.

Hi Arnon,

Nice to chat with you again :). This issue concerns the builder, so I’d recommend reposting your question in that category to be sure it’s picked up by the right team members.

Best, Thomas

Ah, thanks. I moved it.

This error persists in 2020.2.6.

Currently, I am working around it with the following change to the PsychoPy code file: [python-package-directory]/psychopy/experiment/_experiment.py:

@@ -780,7 +806,7 @@
                 try:
                     filePath = filePath.strip('$')
                     filePath = eval(filePath)
-                except NameError:
+                except (NameError, SyntaxError):
                     # List files in directory and get condition files
                     if 'xlsx' in filePath or 'xls' in filePath or 'csv' in filePath:
                         # Get all xlsx and csv files

and this seems to clear the error message.

1 Like

Thanks for the heads-up! I made a little ticket about your fix on the GitHub repo. https://github.com/psychopy/psychopy/issues/3313

1 Like

Thanks for flagging this up! I couldn’t access your Pavlovia link though, could you send the .psyexp file over? This whole bit of code should only execute if '$' in filePath, but from the looks of your error message the value of filePath is this:

Now that you have completed the practice trials, you can begin the actual task! There will be two blocks, each lasting between 8-10 minutes. You will have an opportunity to take a short break in-between the blocks. Feel free to rest and stretch if necessary.

so the root of the problem is probably why this is being passed to the try loop in the first place. Once I know what the parameter’s actual value is I’ll be able to figure out a more stable fix for .7

1 Like

The full value is:

Now that you have completed the practice trials, you can begin the actual task! There will be three blocks, each lasting between 8-10 minutes. You will have an opportunity to take a short break in-between the blocks. Feel free to rest and stretch if necessary.

Again, a “&” announces a LOW REWARD array (opportunity to gain an additional $0.01).
A “$” announces a HIGH REWARD array (opportunity to gain an additional $0.10)
As a reminder, press the “A” key if the target “T” points to the LEFT, and press the “K” key if the target points to the RIGHT.

Please click the Spacebar to begin when you are ready.