[Python] PyInstaller temporary files error when updating

Discussão em 'Python' iniciado por Stack, Outubro 1, 2024.

  1. Stack

    Stack Membro Participativo

    My problem is similar to that described in the linked question. Inno Setup PyInstaller Auto-Update

    I want to create an automatic update mechanism for my PyQt PyInstaller application. My program downloads the installer (Inno Setup) from the server, runs it, and then immediately closes. The installer then installs a new version of my program, after which it should start automatically. However, instead of starting, my program fails with the error "Failed to load Python DLL 'C:\Users\user\AppData\Local\Temp_MEI278082\python3.10.dll.'."

    For some reason, Pyinstaller exe is trying to access temporary files that were deleted after the first version of my application closed. Let me give an example:

    • myProg.exe starts and creates a temporary folder '_MEI123'
    • myProg closes, and the '_MEI123' folder is deleted
    • The installer replaces myProg with the new version
    • When myProg starts, it tries to access '_MEI123', which no longer exists

    It is important to note that if you run the application manually, there are no errors at startup. If you run the installer manually, my program also runs automatically after installation without errors.

    I have tried running the application after installation using both Inno (start after installation) and CMD commands:

    subprocess.Popen(['cmd.exe', '/c', fr'{installer_path} /silent && {exe_path}'], creationflags=0x00000008 | 0x00000200)


    Both of these options returned an error. If you manually call the command through the console:

    start /wait "C:\Users\user\myProg_setup.exe" /silent && "C:\Users\user\myProg.exe"

    there are also no errors.

    That is, somehow, the reason for this error is that the installer for my application was started by my own application. So far, the only solution that has worked is to install the file with a different name. However, this option is not ideal for me.

    Continue reading...

Compartilhe esta Página