Why does a PyInstaller --onefile executable crash on self-restart with temp file warning?

22 hours ago 1
ARTICLE AD BOX

i'm having trouble restarting my python made .exe file, basically it works exactly how it is suppose to work when it's in the .py form, but for some reason when it's in .exe, it just closes, and gives me an error related to local temp files (_MEIxxxxxx), is there any fix to this or do I have to stick with my .py form?

This is the code:

def restart_self(): if getattr(sys, 'frozen', False): executable = sys.executable else: executable = sys.argv[0] print(f"Restarting: {executable}") if getattr(sys, 'frozen', False): subprocess.Popen([executable]) else: subprocess.Popen([sys.executable, executable]) os._exit(0)

Heres what the error says:

Warning

Failed to remove temporary directory: C:\Users\MyUsername\AppData\Local\Temp\_MEI192962

I take this as an error, because the program closes itself after, but either way, its not doing what its suppose to do.

Read Entire Article