Forums

missing static file

[Errno 2] No such file or directory: 'static/data/data_today.tsv'

that's not true, file exist, beside that it could be created: in views.py there codecs.open function with 'w+' should create it

That looks like a relative path name - are you sure the code is running from the correct current working directory? I strongly advise specifying everything as an absolute path because it takes a level of uncertainty out of opening files. If you really can't stand the idea of absolute paths (but that really is the best practice) then you could make sure you're always running in the right working directory with an os.chdir() at the start of your script.

If the paths issue isn't causing the problem, perhaps there's a race condition whereby the code that attempts to open the file runs before the code that created it? If the backtrace is from the code that attempts to create it, it's likely that the parent directory doesn't exist - remember that opening a file for writing won't create the parent directory, that has to already exist. If you need to ensure the parent directory already exists, call os.path.isdir() to check for its existence and then os.makedirs() to create it if necessary (instead of calling os.path.isdir() you could just call os.makedirs() and catch the exception, but this is a little fragile because unless you examine the exception very carefully you'll end up ignoring a failure to create the directory).