'Why is my python executable not able to create files but can access data on runtime?

A little bit of context:

  • I have made a password manager in python
  • I then packed it into a single executable using: pyinstaller --onefile password_manager.py

Okay first I want to specify that the script works properly when I run it through the password_manager.py file, the executable version also runs properly and when I e.g. create a user and I save the data in a new json file. I'm able to access it on runtime but when I actually close the shell and the program stops running it's like the data has all been lost and or deleted. I'm looking for a way for the required data to remain on my drive like they do when I run password_manager.py on its own.

P.S. I can view hidden files in my computer too.

P.S.S. The link to the code is here: code

My file structure when I run it through password_manager.py

Here is the executable showing some random Data I recently added without closing and restarting the program. These information was supposed to be stored in /data/users.json and /data/password (and is stored there when I just use password_manager.py) but when I actually exit the application they are not present in any way when I rerun the executable(neither the directories that were supposed to be created nor the files).

Simple replication:

#mkdir.py
import os
os.mkdir("stack")

shell:

pyinstaller --onefile mkdir.py

I also sadly couldn't find a way to include the executable in this question but you can replicate it with the given command.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source