在Pyinstaller中为使用子进程调用的cli程序指定依赖关系的最佳方法

时间:2017-07-03 15:33:49

标签: python pyinstaller

假设我有一个用Python 2.7编写的命令行程序。命令行实用程序调用执行另一个命令行程序的函数。命令执行如下:

public function store()
{

if(!auth()->attempt(request(['email','password']))) 

    return back();
}
 return redirect()->home();
}

我想使用PyInstaller打包程序。我按照添加二进制依赖项的说明操作并运行pyinstaller,如下所示:

import subprocess
def exec_command(*args):
    process = subprocess.Popen(args,stdout=subprocess.PIPE)
    output, error = process.communicate()
    return output, error

当我将程序打包为文件夹时,这可以工作,然后我可以通过简单传递这样的列表来调用打包程序中的可执行文件:

pyinstaller cli.py --name <new_name> --add-binary <path_to_exec>:.

但是,如果我将程序打包为文件,则无效。如果我这样做,我会收到以下错误:

exec_command('<path_to_exec>',arg1,arg2)

所以我的问题是,当打包为文件时,如何在命令行工具中调用此脚本?

1 个答案:

答案 0 :(得分:0)

最后发现这个post详细说明了当pyinstaller捆绑为单个文件应用程序时如何访问由pyinstaller创建的临时文件夹。该功能也适用于具有文件夹打包应用程序的情况。