I'm currently developing a python application for windows and i want to share it to my friends. To do so, I converted my python files in to an executable using pyinstaller. I then created an installer and an updater which retrieves the files in a github repository, downloads them and unzips them to be used.
I now want to create an uninstaller so it is easier to delete the application but I cannot find a great way to do it.
I tried to delete the directory containing the installation but I keep getting permission errors.
Is there another great way to do it ?
You could create a separate uninstallation script that is placed outside the installation directory, and it can call the uninstaller script from within the directory.
1.Create an uninstallation script (uninstall.py) outside the installation directory.
2.Inside uninstall.py, execute the uninstaller script (uninstaller.py) located within the installation directory using os.chdir() to change the working directory.
Example:
With this, users can run uninstall.py from outside the installation directory, and it will execute uninstaller.py located within the installation directory, effectively removing the application without encountering permission issues ———————————————————————————————————
Here’s how you could modify the script to make it delete itself after uninstalling the application:
In this updated version, after uninstalling the application and removing the installation directory, the script attempts to delete itself using
os.remove(__file__). This line removes the file that is currently being executed (uninstaller.py).