Suppose I have a command line program written in Python 2.7. The command line utility calls a function which executes another command line program. The command is executed like this:
import subprocess
def exec_command(*args):
process = subprocess.Popen(args,stdout=subprocess.PIPE)
output, error = process.communicate()
return output, error
I would like to package the program using PyInstaller. I've followed the instructions for adding a binary dependency and run pyinstaller like this:
pyinstaller cli.py --name <new_name> --add-binary <path_to_exec>:.
This works when I package the program as a folder and I can then call the executable in my packaged program by simple passing a list like this:
exec_command('<path_to_exec>',arg1,arg2)
However this does not work if I package the program as a file. If I do so I get the following error:
OSError: [Errno 2] No such file or directory
Failed to execute script cli
So my question is, how can I call this script in my command line tool when packaged as a file?