Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用执行python脚本隐藏控制台_Python_Python 3.x_Pyinstaller - Fatal编程技术网

使用执行python脚本隐藏控制台

使用执行python脚本隐藏控制台,python,python-3.x,pyinstaller,Python,Python 3.x,Pyinstaller,我正在尝试在Windows10上使用pyqt5模块,使用pyinstaller编译在Python3中构建的python脚本,pyinstaller在运行时隐藏窗口 为了编译脚本,我执行了以下命令: pyinstaller --onefile --icon=app.ico --clean --noconsole app.py 但我得到的可执行文件无法运行,因此我再次通过以下命令编译脚本: pyinstaller --onefile -w --icon=app.ico app.py 如果使用

我正在尝试在Windows10上使用pyqt5模块,使用pyinstaller编译在Python3中构建的python脚本,pyinstaller在运行时隐藏窗口

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

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标志隐藏控制台

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

pip install auto-py-to-exe

我也试过了,但不起作用,它正在使用pyinstaller的方式-w或--windowed或--noconsole对我隐藏控制台非常有效。也许重新安装pyinstaller可以解决您的问题是的,它与pyqt5一起工作。并且你必须在一个目录中包含像图片等文件(如果你没有)