Looks like cgitb is naive to windowed applications. Here it writes to a file-like attribute which gets set to sys.stdout. In a windowed application, sys.stdout is None so that line will raise some kind of NoneType has no attribute write error. The reason why it worked on older PyInstaller versions is because PyInstaller used to set sys.stdout to a placebo object with no-op .write() methods but it got scrapped because it led to other issues. You might be able to fix it by running sys.excepthook.file = open(os.devnull, "w") imediately after calling enable() or, failing that, boycott the enable() function and run this line directly but adding file = open(os.devnull, "w") to the Hook() constructor.