pyinstaller failed to execute script code example

Example 1: pyinstaller failed to execute script pyi_rth_pkgres

pyinstaller --hidden-import=pkg_resources.py2_warn --onefile example.py

Example 2: pyinstaller Failed to execute script pyi_rth__tkinter

pyinstaller --onefile --add-binary='/System/Library/Frameworks/Tk.framework/Tk':'tk' --add-binary='/System/Library/Frameworks/Tcl.framework/Tcl':'tcl' PDT_Admin_Console.py

Example 3: pyinstaller “failed to execute script” error with --noconsole option

import sys, os 
    def resource_path(relative_path):
        if hasattr(sys, '_MEIPASS'):
            return os.path.join(sys._MEIPASS, relative_path)
        return os.path.join(os.path.abspath("."), relative_path)