ValueError: stat: path too long for Windows Error

Hello,

I’m getting below error message from my experiment when I try to update it. Before 2 weeks ago, I could update with no problem but now I get below error.

Could you please help me?

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 213, in writeScript
    self_copy.flow.writeFlowSchedulerJS(script)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\flow.py", line 290, 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 841, in getResourceFiles
    thisFile = getPaths(thisParam.val)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\_experiment.py", line 767, in getPaths
    if os.path.isfile(thisFile['abs']):
  File "C:\Program Files\PsychoPy3\lib\genericpath.py", line 30, in isfile
    st = os.stat(path)
ValueError: stat: path too long for Windows

It looks like the most likely explanation is a name clash.

1 Like

As “name clash”, do you mean a filename or variable name problem?
Because according to these references I’ve understand such kind of problem. If so, I’ve never changed the name of any file. On the other hand I have to check all new codes for a variable name problem.

I think that the issue is that a variable name matches a filename used by PsychoPy. What code/variables have you added since it last worked?

1 Like

After your first reply, I’ve checked whole new codes. The problem is strange, at least for me (who has not many experience at coding). There was a long if - elif loop (1 if plus 44 elif). I’ve divided code to 9 different codes (each one is 1 if plus 4 elif) and the error message has gone. Does it make sense or also it is strange for you?

That many elifs sounds strange, though I guess I get close to that with free recall keyboard code. Since that translates to JS as nested brackets then it may be that there’s a maximum bracket depth.

1 Like

To Update here, also just encountered this whilst working on someone’s project - in this case the code component had >100 lists each containing >175 elements.

To anyone following this thread - If you encounter this error and have hard coded a large number of variables in this way - see if you can instead set the variables in a .csv file - put that as the conditions file in a loop and load them in that way (such as here)

1 Like