I'm trying to create an executable file out of my python project. I'm using the function 'make_executable' to build an executable file.
Running the command to add data raises an error like: pyinstaller: error: unrecognized arguments: --add-data C:\Users<>... --add-data: C:\Users<>...
def make_executable(main_script: str, files_to_add: List[str], target_location: str = None,
name: str = 'app', single_file: bool = True) -> None:
"""
Creating an executable file out of the provided parameters.
:param main_script: Main script of the application.
:param files_to_add: A list of files that are crucial to the project.
:param target_location: Where to store the executable file.
:param name: Name of the executable file.
:param single_file: Determine whether a single file or a directory is to be created.
:return: None.
"""
args = [main_script, f'--name {name}']
if target_location is not None:
args.append(f'--distpath {target_location}')
if single_file:
args.append('--onefile')
for file in files_to_add:
args.append(f'--add-data {file}')
PyInstaller.__main__.run(args)
I've also tried using something like
- --add-data C:\Users<>\xyz;. --add-data C:\Users<>\abc;.
- --add-data "C:\Users<>\xyz;." --add-data "C:\Users<>\abc;."
Note: Each backslash is escaped.
What can I do to add the required data? Any help on this issue is appreciated!