Python 隐藏使用 PyInstaller 创建的 .exe 文件的控制台
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41129537/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hide the console of an .exe file created with PyInstaller
提问by Matteo Secco
I want to make my program executable. I used TkInter to write the GUI, and I read somewhere that you have to save your file as .pyw to hide the console when the program is executed. The problem is that after making it an executable with PyInstaller, the console shows up again, even though the file converted was .pyw. How can I hide the console also in the .exe file?
我想让我的程序可执行。我使用 TkInter 来编写 GUI,我在某处读到你必须将文件保存为 .pyw 以在程序执行时隐藏控制台。问题是,在使用 PyInstaller 使其成为可执行文件后,即使转换后的文件是 .pyw,控制台也会再次出现。如何在 .exe 文件中也隐藏控制台?
回答by Maurice Meyer
Did you try --windowed
command line flag ?
您是否尝试过--windowed
命令行标志?
回答by liamhawkins
What are you using to make the executable?
你用什么来制作可执行文件?
If you use py2exeand you use:
如果您使用py2exe并且您使用:
setup(windows=[pythonscriptnamehere])
in the setup script instead of:
在安装脚本中而不是:
setup(console=[pythonscriptnamehere])
it will run the executable without launching a terminal in the background.
它将运行可执行文件,而无需在后台启动终端。