'pyinstaller exe multiple files result in error of can't find directory

Ppl

I compiled a simple code it works on my machine but when i try to run the exe from another machine I get an error that it can't find the script which is called from main

so I have to python files main. Script

I am calling Script from main using this function

def execfile(filepath, globals=None, locals=None):
    if globals is None:
        globals = {}
    globals.update({
        "__file__": filepath,
        "__name__": "__main__",
    })
    with open(filepath, 'rb') as file:
        exec(compile(file.read(), filepath, 'exec'), globals, locals)

the way I am calling is this, very simple minded approach

 execfile("Script.py",globals=None,locals=None)

when i try to run it from another machine i get the error no such file or directory Script.py

I want to understand since the scripts are called from one another why is pyinstaller exe is not having both files, i have tried the add-data but i dont seem to understand what does it do exactly and it didn't work in my case to have the exe running on other machines

python 3.9.10 windows 11



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source