I have an app that accesses .txt files that contains user data from a subdirectory where the .py file is located. After Pyinstaller is used to compile the .py file to a .exe file the path changed to AppData\Local\Temp\_MEI185962\<subdirectory>\<user data.txt>
when I print the path. My question is how do I come up with the path to where the .exe
file is all the time, because I want to make my program be distributeable so I don't want to use a hardcoded path or if I move the folder around.
So for example if I have my program.exe in the directory C:/Users/<username>/Desktop/project
then how do I access te subdirectory C:/Users/<username>/Desktop/project/data
. I tried importing os.path and had
path.dirname(path.realpath(__file__))
to get the path, but it is still pointing to the C:\User\<username>\AppData\Local\Temp\_MEI185962\<subdirectory>\<user data.txt>
.
I am new to compiling so I don't know much about pyinstaller at all. I also can't seem to find any thing on this issue either.