How to write to data files in executable created with pyinstaller - python-3.5

I'm making onefile executables with pyinstaller on windows 10. I'm including data files (pickle files) by editing the .spec file...
How can I store changes made to these files during run time? My understanding is that the data files are copied to a temp directory during execution. I can read from the files using the path I get from sys._MEIPASS but the changes I write are lost after restarting the program.
Is there a way to write to pickle files stored inside the exe?

Related

How to convert all nodejs files into one executable file

Currently, I'm using pkg module to convert it to a single exe file and it does only one main.js file, but on the root folder, it has multiple *.js files that are needed to run along with this. I want all packages and files to be executed with a single click without exposing the files or installing them on the machine.

How to create an exe that deletes the dir it is in (including itself)

I am a python developer and I made a program and packed it with inno setup.
inno setup automatically creates 2 files one of them a unins000.dat file and a unins000.exe file
when starting the .exe it will fully uninstall everything that you installed including the exe itself
now the 2 problems I have with this is:
it also creates a .dat file and I just want 1 exe to uninstall the entire program
the exe and dat files are both called unins000 and not just uninstall
(I have already tried renaming them but then the exe just doesn't work anymore)
so I found a way to disable the creation of these files
so now I am trying to create a .exe file that can delete the entire directory it is in including itself
I have started using python so I coded a script which deletes the entire dir the python script is in
but when I package it into an exe using pyinstaller it doesn't work anymore
How can I make an executable that when run deletes the directory where it is in including itself?
You can create exe that after start makes copy of itself into temp folder, then starts this copy and stops original process. Then the second process can delete whole folder. Then after some time OS should delete file left in temp folder on it's own.

How do I access the directory of my NSIS Installer inside a Zip File to extract that Zip File?

I want to extract a ZIP File with the .exe inside.
I want to execute the .exe inside the Zip to extract the Zip File.
Already tried it by executing: ZipDLL::extractall "$EXEDIR" "$DESTINATION"
I think that does not work, cause the .exe is stored in the TEMP Folder when opened, so it cannot find the.Zip file
So how do I extract that Zip when executing the .exe from inside the Zip?
Thanks for answers!
Your question does not make a lot of sense, you should just put the files inside the installer and not have a zip file at all.
Even if it made sense, it is not possible because where a exe is executed from when you double click it inside a zip file depends on the zip program you are using and there is no way of getting the path of the zip it was extracted from.
If for some reason you want to be able to update the files inside the zip file without rebuilding the installer you can use a cab file instead. The CabX plug-in supports extracting from cab files appended to the installer exe.

SQLite3 db is not getting included in the compiled directory pyinstaller

Here are my files that i have in a folder ready for compile...
After using pyinstaller i now have my compiled folder complete...
However, as you can see codes.db file is not in the folder as expected!
That is until i click the .exe to launch...then all of a sudden the .exe spits out an empty codes.db file showing 0kb and have no tables. I am assuming at this point that because the codes.db is missing the .exe creates an empty .db with the same name.
How can i make sure that my sqlite3 db is included in the compile? It needs to still have its read/write capability.
EDIT
Im using Windows 10 and Visual Studio 2017.
I don't see your .spec file. Running
pyinstaller file.py
produces a file.spec file. This file should be edited by the user to fit his needs. One hassle free way i found is to have the db in a folder and add the folder, setting datas in analysis to
[
( './db/*', 'db' ),
]
You can view my complete answer on SO here: sqlite + PyQt5 to standalone exe - Python 3.6.3 + Pyinstaller

How to include all necessary files and folders in python executable file using pyinstaller on ubuntu?

I want to keep all the python script files hidden and want to give executable file to the user.
Here's the screeenshot of the folder:
I am running it from the webroot directory of a project.I am going to run my project on the local host. In the Al3ViewerController I have given path to the main.py/ exe main file using shell_exec. But I need to keep the folder containing all the other python and DB files and I cannot do that for code security purpose, hence an exe file to run. could be --onefile / folder. I would want to remove that folder completely and just run from the executable file

Resources