hide console with executing python script

你离开我真会死。 提交于 2021-02-10 06:48:34

问题


I am trying to compile my python script built in python 3 using pyqt5 module on windows 10 using pyinstaller which hides the windows while running.

To compile my script I executed following command:

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

But the executable I got didn't worked so again I compiled my script by following command:

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

Still the output executable is not working if --console/-w/--windowed argument is used.

How can I make my executable run without console?

this is the script i try to execute it

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

Thanks


回答1:


pass -w or --windowed or --noconsole flag to hide console.

Try GUI pyinstaller by installing auto py to exe. It makes you more easier to compile your script.

pip install auto-py-to-exe


来源:https://stackoverflow.com/questions/54566381/hide-console-with-executing-python-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!