def bundle_dir ( ) : if frozen ( ) : directory = sys . _MEIPASS else : directory = os . path . dirname ( os . path . abspath ( stack ( ) [ 1 ] [ 1 ] ) ) if os . path . exists ( directory ) : return directory
how to determine that path at runtime on any machine from python program
Handle resource management within an executable file .
def bundle_dir():
    """Handle resource management within an executable file."""
    if frozen():
        directory = sys._MEIPASS
    else:
        directory = os.path.dirname(os.path.abspath(stack()[1][1]))
    if os.path.exists(directory):
        return directory