For those who using nuitka with onefile mode, just use sys.executable
sys.executable
It will return something like /tmp/onefile_xxxxxxxx/python3, and then you can os.path.dirname it to get its parent dir
/tmp/onefile_xxxxxxxx/python3
os.path.dirname