Recently, I created a small Python project and decided to compile it into one .exe file (with pictures, sound, etc ...). And I managed to do it, but there was a problem when overwriting files in the application when it was restarted. That is, when I launch the application and somehow make changes there, the file is overwritten, and I can observe these changes, but when the application is closed, all changes disappear. How to make all changes be saved even after the application is closed?

The problem is solved, here is the link to the source: https://github.com/mygazztop/FastNumbers/blob/master/results/FastNumbers(beta).exe

Closed due to the fact that Sergey Gornostaev , insolor , Air , aleksandr barakin , Dmitry Kozlov, 29 December '18 at 11:49 , are off topic.

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Sergey Gornostaev, insolor, Air, aleksandr barakin, Dmitry Kozlov
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Please post your small project. - S. Nick
  • Maybe someday I will do it, but this is unlikely to be in the near future. - Mikhail Muratov

1 answer 1

What you call compilation is simply the process of creating a self-extracting archive, including a Python interpreter, a set of necessary libraries and files for your project. At startup, all this junk is unpacked into a temporary directory and started from there. Upon completion, the temporary directory is deleted. If you are trying to edit packed files, then each time you start you are working with a new copy, which is obviously useless.

You need to create or copy the required file to some permanent directory. For example, in the user profile directory or the directory in which the program executable file is located.

  • Good idea, I myself thought so to do, but if I create a file in the permanent directory of the person who downloaded the application, this will cause a number of problems. For example, I have no idea where to put this file. And if the user thinks that this file poses some kind of threat and deletes it, maybe by accident? If the application itself cannot be changed, suggest a way to save the file described by you. - Mikhail Muratov
  • one
    Users usually do not even log in to AppData, let alone remove something from there. There and save. Or use the registry if the data structure allows it. - Sergey Gornostaev
  • Thank. Made with precision as you said. A link to the project put in the text of the question. - Mikhail Muratov