0

I have used Pyinstaller to pack my script as onedir EXE, then installed to Program Files folder. i used this line to save a json to a file:

json.dump(data, open("data_file.json",'w'))

on some computers the file saved to where EXE is which is what i want, but others save it to different locations.

so when i try to get the file using json.load it says not file found:

json.load(open("data_file.json"), encoding="utf-8")

How can i solve this issue so the script only save files to the same EXE directory?

1 Answers1

0

The cause of the problem is related to writing permission on windows. so instead of writing app data to the Program Files folder which is not recommended, you need to write the data to APPDATA folder.

i have used the code posted by giuliano-oliveira and it works perfectly cross platform. get_user_data_dir