pyinstaller -w不适用于子进程

时间:2019-01-27 15:27:37

标签: python compilation subprocess pyinstaller

我有以下代码在IDLE中工作正常,并将命令输出到文本文件,没有弹出窗口。

s1 = subprocess.check_output('netstat -aonf | findstr "LISTENING"', shell=True)
output = s1.decode("utf-8")
lines = output.split('\n')


for line in lines:
    #print(line)
    file = open("outp.txt", 'a')
    file.write('\n')
    file.write(line)
    file.close
    ()

但是当我使用带有-w选项的pyinstaller编译为exe时,总是无法运行并显示以下错误 "failed to execute script"。如果不使用-w选项进行编译,则该exe可以正常运行,但会弹出一个窗口。

我环顾了许多类似的线程,这些线程说-w选项的相同问题使exe无法运行。我试图重定向标准输出,但收到returned non-zero exit status 1错误。

可以更改代码以防止pyinstaller中的错误吗?

0 个答案:

没有答案