I have a script which needs to be able to save its own full path into a variable. So far I have tried:
sys.argv[0]
os.path.realpath(__file__)
os.path.abspath(__file__)
these all work with the regular python script I have. However once I convert it to an executable with pyinstaller, the above methods no longer work for getting the path of the .exe. They either detect the .exe as a .py or simply don't detect it at all. Why is this so and what method can I use that will always get the name of the script whether it is a .py or .exe. Is there a function that can get the full path of the file whether it is a normal .py file or a python .exe file. I'm on python 2.7 using windows 10