Hi Ed,
I suspect that the problem is that you are not explicitly setting the path to write your text file into - if you are using onefile mode then the current working directory is either inside a zip file or a temporary location that you may not have write permissions for.
This is given away by:
which is
not a valid file path.
I would try one or more of:
Hope that helps.
Steve Barnes
From: pyins...@googlegroups.com <pyins...@googlegroups.com>
On Behalf Of Ed May
Sent: 13 March 2022 00:23
To: PyInstaller <pyins...@googlegroups.com>
Subject: [PyInstaller] Crash when writing to a txt file from within a --onefile .app ?
Hi everyone,
I am new to PyInstaller and having some trouble with one area? I was hoping that someone might know the right place to look for the method to use?
Using a very simple PyQt6 GUI - I have code that outputs a small text file when the user pressed a button. This uses the normal `with open("filename.txt", "w") as f:` python pattern. When I run the app using my normal python interpreter, it all works as expected: I get a small window and when you click the button, a txt file is created in the same folder as the script.
so that is all fine.
I am able to run PyInstaller just fine, and the build all seems to go normal. I get a good .app file when it is done.
I can then run the .app file just fine, and it opens with the same GUI as before the build.
BUT: as soon as I click the button in the GUI, the app crashes and I get an error report.
I am not sure where I'm going wrong there, or if I should be:
a) Using a different method than the with open(...)... syntax when using PyInstaller?
b) Is there something I should be setting in the .spec file perhaps?
# Environment / Versions:
Any suggestions are much appreciated!
thanks very much,
-Ed
--
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
pyinstaller...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/16d1a387-27e1-4f2e-b69b-38c16fdfd3f2n%40googlegroups.com.