I am attempting to debug my pythonw script that I am writing because it sort of works when launching it through idle, but it crashes when launching it through cmd or double-clicking on it. the code i have at the moment that's failing is
import sys
sys.stdout = open("mylog.txt", "w")
sys.stderr = open("errors.txt", "w")
print("hello world")
import thisisgonnafail
print(sys.executable)
It does create the file, as I'm told by notepad++ that the files have been updated, but the files are both always empty, even though they should have the error message from the import that is set up to fail, and the print line