It's not a bug/problem per se, it's the design of a onefile executable: it always unpacks into a temp directory, runs, then delete the temp dir. I'd suggest storing the file in a persistent location instead. I doubt you want to store it back into the packed program, since this involved modifying an executable, which most OSes require elevated permissions / frown upon.
On Tue, Feb 19, 2019 at 9:03 AM Peter Petocz <[email protected]> wrote: > Hi All, > > I have created an application with PyQt5 and bundled it using Pyinstaller. > The application loads login info from a login.properties file that is > stored in the same directory as the .py file that starts the app. > > As suggested here > <https://blog.aaronhktan.com/posts/2018/05/14/pyqt5-pyinstaller-executable> I > am modifying the path with the following function: > > import os, sys# Translate asset paths to useable format for PyInstaller > def resource_path(relative_path): > if hasattr(sys, '_MEIPASS'): > return os.path.join(sys._MEIPASS, relative_path) > return os.path.join(os.path.abspath('.'), relative_path) > > What it causes, is that it creates a temporary folder called _MEIPASS, > that contains the files, like my login.properties. > > In the app, I want to save the login.properties info with the following > function: > > self.loginFile = resource_path('./login.properties') > def save_login_info(self): > config = configparser.ConfigParser() > config.read(self.loginFile) > > pw = self.login_ui.password_lineEdit.text() > un = self.login_ui.username_lineedit.text() > token = self.login_ui.token_lineEdit.text() > alias = self.login_ui.gmail_alias_lineedit_2.text()... > config.set('Login', 'password', pw ) > config.set('Login', 'username', un ) > config.set('Login', 'security_token', token ) > config.set('Login', 'alias', alias) > > with open(self.loginFile, 'w') as loginfile: > config.write(loginfile) > > print('Login info saved') > > So the changed login info is saved to the temporary file/folder and it is > not saved to the 'original' file. > > Any ideas how to mitigate this problem? > > -- > You received this message because you are subscribed to the Google Groups > "PyInstaller" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/pyinstaller. > For more options, visit https://groups.google.com/d/optout. > -- Bryan A. Jones, Ph.D. Associate Professor Department of Electrical and Computer Engineering 231 Simrall / PO Box 9571 Mississippi State University Mississippi State, MS 39762 http://www.ece.msstate.edu/~bjones bjones AT ece DOT msstate DOT edu voice 662-325-3149 fax 662-325-2298 Our Master, Jesus Christ, is on his way. He'll show up right on time, his arrival guaranteed by the Blessed and Undisputed Ruler, High King, High God. - 1 Tim. 6:14b-15 (The Message) -- You received this message because you are subscribed to the Google Groups "PyInstaller" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/pyinstaller. For more options, visit https://groups.google.com/d/optout.
