Sys.path changes when running an app with debug on


I wrote a dash app where I call several other classes that I have distributed in folders elsewhere. In my sys.path these folders are indicated so that Python can always find them.

I discovered that when I run the Dash App with .run_server (debug = True) , and when I print the sys.path variable, the variable changes! When debug = True, the app always executes twice before actually starting up (I am not sure why this is the case, it must be explained somewhere, but I have not been able to find it). On the first run, the sys.path is correct, but on the second run the sys.path is changed and in particular the paths to the folders that contain my classes is gone, so that the app stops with an error that is cannot (of course) import these classes.

I can circumvent the problem by added the sys.path variables explicitely at the start of the app script, but I think this is silly.

Does anyone have any idea?