If you are running a frozen python script (frozen using py2exe) from a directory and drive different from where the script is present, what is the best way to determine the path
Another approach which works with cxFreeze when running from another drive even using PATH:
import sys
if hasattr(sys, 'frozen'):
print(sys.executable)
else:
print(sys.argv[0])
From Python:
H:\Python\Examples\cxfreeze\pwdme.py
From command line:
D:\>h:\Python\Examples\cxfreeze\dist\pwdme.exe
h:\Python\Examples\cxfreeze\dist\pwdme.exe
Using PATH:
D:\>pwdme.exe
h:\Python\Examples\cxfreeze\dist\pwdme.exe