settings.txt is stored and processed in a compiled single-phase application, but is not written. This works before compiling Pyinstaller when the file is in the same directory as the script.
The application is compiled from the terminal:
pyinstaller script.spec script.py --windowed --onefile
a.datas installed in the specification file as:
a.datas += [('settings.txt','/path/to/settings.txt', "DATA")]
and the file is read correctly in the application:
with open(resource_path('settings.txt'), 'r') as f2
However, the file is not updated when trying to overwrite the file:
def OnExit(self, event): with open(resource_path('settings.txt'), 'w') as f2: f2.write('update') self.Destroy()
resource_path defined as:
def resource_path(relative_path): """ Get absolute path to resource, works for dev and for PyInstaller """ try:
python pyinstaller
Phillip Dec 10 '16 at 7:14 2016-12-10 07:14
source share