【问题标题】:Pyinstaller issue with subprocess.check_output on onefile executable under windowsPyinstaller 在 windows 下的 onefile 可执行文件上的 subprocess.check_output 问题
【发布时间】:2014-01-31 15:14:42
【问题描述】:

需要运行 subprocess.check_output 才能在我的应用程序中捕获 7zip 的输出。我使用的简单代码是

output = subprocess.check_output(["path/to/7zip", "l", "path/to/archieve"], shell=True)
print output

正如预期的那样,当我从 IDE 运行它时它运行良好。使用 pyinstaller 编译为 onefile 可执行文件后,同样会变得疯狂并且无法正常工作。即使将脚本转换为可执行文件,另一个子进程命令subprocess.call 也能正常工作。如何在可执行文件中使用subprocess.check_output?

我使用以下内容:-

Windows 7
Python 2.7.5
PyQt4
Pyinstaller 2.1

感谢任何帮助。

【问题讨论】:

    标签: python windows subprocess pyinstaller


    【解决方案1】:

    好的。自己解决了。使用os.popen 命令完成相同的任务。为了完整起见,将解决方案代码发布在下面:-

    out = os.popen("path/to/7zip l path/to/archieve").read()  
    print out
    

    【讨论】:

      猜你喜欢
      • 2014-12-22
      • 1970-01-01
      • 2019-07-18
      • 2019-08-29
      • 2018-04-13
      • 2020-07-09
      • 2020-06-26
      • 1970-01-01
      • 2014-01-03
      相关资源
      最近更新 更多