| Reference | Downloads | Github

ValueError: stat: path too long for Windows Error


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\", line 1221, in onPavloviaSync
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\", line 719, in fileExport
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\", line 73, in generateScript
    compileScript(infile=exp, version=None, outfile=filename)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\", line 242, in compileScript
    _makeTarget(thisExp, outfile, targetOutput)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\", line 214, in _makeTarget
    script = thisExp.writeScript(outfile, target=targetOutput, modular=True)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\", line 213, in writeScript
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\", 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\", line 841, in getResourceFiles
    thisFile = getPaths(thisParam.val)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\", line 767, in getPaths
    if os.path.isfile(thisFile['abs']):
  File "C:\Program Files\PsychoPy3\lib\", 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