带有 --noconsole 的 Windows 上的 pyinstaller 根本不起作用 [英] pyinstaller on Windows with --noconsole simply won't work

查看:87
本文介绍了带有 --noconsole 的 Windows 上的 pyinstaller 根本不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当简单的 GUI (wxPython) 应用程序并且运行良好.我使用的是 Windows 7.
使用 pyinstaller-w(或 --noconsole--windowed)编译并运行它时,我可以看到一个控制台窗口一毫秒,然后它关闭.GUI 应用程序将无法运行.
不使用 -w 编译将生成一个带有控制台窗口的工作应用程序.

I have a fairly simple GUI (wxPython) app and is working great. I'm using Windows 7.
When compiling it using pyinstaller with -w (or --noconsole or --windowed) and run it, I can see a console window for a millisecond and then it shutdown. The GUI app won't run.
Compiling without the -w will produce a working app with a console window.

我在这里遗漏了什么?

推荐答案

我猜你是在以某种方式启动一个子进程,当 Python 在没有控制台窗口的情况下运行时,它会变得一团糟.我必须解决与此相关的三个问题:

I would guess that you are somehow launching a subprocess that gets messed up when Python runs without a console window. I have had to solve three problems related to this:

  1. multiprocessing 模块需要设置环境变量 当它产生工作进程时.
  2. subprocess 模块需要明确处理stdinstdoutstderr,因为没有为要继承的子进程设置标准文件句柄.
  3. 子进程会创建一个控制台窗口,除非您告诉它不要.
  1. The multiprocessing module needs to set an environment variable when it spawns worker processes.
  2. The subprocess module needs to explicitly handle stdin, stdout, and stderr, because the standard file handles aren't set for subprocesses to inherit.
  3. The subprocess creates a console window, unless you tell it not to.

这篇关于带有 --noconsole 的 Windows 上的 pyinstaller 根本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆