隐藏控制台执行python脚本

问题描述 投票:1回答:1

我试图编译我的Python脚本内置在Python 3使用pyqt5模块上使用pyinstaller运行时,它可以隐藏Windows视窗10。

要编译我的剧本我执行以下命令:

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

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

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

使用窗口参数 - 犹若--console / -w /输出可执行文件无法正常工作。

我怎样才能让我不带控制台可执行的运行?

这是我的脚本尝试执行

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()

谢谢

python python-3.x pyinstaller
1个回答
2
投票

通过-w或--windowed或--noconsole标志隐藏控制台。

通过安装自动PY为EXE尝试GUI pyinstaller。它使你更容易编写脚本。

pip install auto-py-to-exe
© www.soinside.com 2019 - 2024. All rights reserved.