通过执行 python 脚本隐藏控制台

hide console with executing python script

我正在尝试使用 pyinstaller 在 windows 10 上使用 pyqt5 模块编译内置于 python 的 python 脚本,该脚本隐藏了 windows 而 运行宁.

为了编译我的脚本,我执行了以下命令:

pyinstaller --onefile --icon=app.ico --clean --noconsole app.py

但是我得到的可执行文件没有工作,所以我再次通过以下命令编译我的脚本:

 pyinstaller --onefile -w --icon=app.ico  app.py

如果使用 --console/-w/--windowed 参数,输出可执行文件仍然不工作。

如何在没有控制台的情况下制作可执行文件 运行?

这是我尝试执行的脚本

import threading
import subprocess
import sys
import time

f = open("build\eco.txt", "x")
f = open("build\sou.txt", "x")

def run_process(path):
    cmd = 'python %s' % path
    process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    for line in iter(process.stdout.readline, ''):
        sys.stdout.write(line)


t1 = threading.Thread(target=run_process, args=('py1.py',))
t2 = threading.Thread(target=run_process, args=('py2.py',))
t3 = threading.Thread(target=run_process, args=('py3.py',))
t4 = threading.Thread(target=run_process, args=('py4.py',))
t5 = threading.Thread(target=run_process, args=('py5.py',))


#start
t1.start()
t2.start()
t3.start()
t4.start()
t5.start()

# Waiting
t1.join()
t2.join()
t3.join()
t4.join()
t5.join()

谢谢

传递 -w 或 --windowed 或 --noconsole 标志以隐藏控制台。

通过将 auto py 安装到 exe 来尝试 GUI pyinstaller。它使您更容易编译脚本。

pip install auto-py-to-exe