1

I've made an .exe file by pyinstaller and distributed some users.

After distribution, if there is an bug, I re-freeze the program and re-distribute it, now. I thought, this is a very inefficient way.

I want to upload new version of script in my webserver, then the program is auto-updated by itself in a user computer.

Is there a good method?

Thanks in advance

  • Does this answer your question? [Auto updating a python executable generated with pyinstaller](https://stackoverflow.com/questions/20617997/auto-updating-a-python-executable-generated-with-pyinstaller) – Grismar Dec 07 '20 at 07:33
  • I read the answer. But I wonder if there is the latest method to auto-update. – hoesang choi Dec 07 '20 at 07:54

1 Answers1

0

Hello here is a post which which I answered ago this should work for you Answer to this

here is the code

import tkinter as tk #for you it is pyqt5
from tkinter import * #MessageBox and Button
import requests #pip install requests
import os #part of standard library
import sys #part of standard library

VERSION = 4

b1 = Button(frame, text = "Back", command = homepage)
b1.pack(ipadx= 10, ipady = 10, fill = X, expand = False, side = TOP)

checkupdate = Label(frame, text = "Looking for updates", font = ("Arial", 14))
checkupdate.pack()

try:
    link = "https://raw.githubusercontent.com/SomeUser/SomeRepo/main/SomeFolder/version.txt"
    check = requests.get(link)
    
    if float(VERSION) < float(check.text):
        mb1 = messagebox.askyesno('Update Available', 'There is an update available. Click yes to update.')
        if mb1 is True:
            filename = os.path.basename(sys.argv[0])

            for file in os.listdir():
                if file == filename:
                    pass

                else:
                    os.remove(file)

            exename = f'NameOfYourApp{float(check.text)}.exe'
            code = requests.get("https://raw.githubusercontent.com/SomeUser/SomeRepo/main/SomeFolder/NewUpdate.exe", allow_redirects = True)
            open(exename, 'wb').write(code.content)

            root.destroy()
            os.remove(sys.argv[0])
            sys.exit()
            
        elif mb1 == 'No':
            pass
        
    else:
        messagebox.showinfo('Updates Not Available', 'No updates are available')

except Exception as e:
    pass
Dodu
  • 109
  • 2
  • 8
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31451807) – Muhammad Mohsin Khan Apr 05 '22 at 09:38