【发布时间】:2019-01-02 02:37:41
【问题描述】:
在使用 pyInstaller 创建 exe 时,我正在努力实现子进程。
我有一个程序,它有一个 gui (tkinter),其中多个按钮都有它们的 subprocess.popen()。有一个通过 ssh 的命令发送到需要一些时间才能完成的网络设备。
在 pyCharm 中,这很顺利。 当我使用 pyInstaller 创建 exe 时,出现以下错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter\__init__.py", line 1699, in __call__
File "gui.py" in line 197 in wrapper
File "subprocess.py", line 707, in __init__
File "subprocess.py", line 990, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
key not found: process1
gui.py 第 197 行的相应代码是:
proc = subprocess.Popen(['python', r'commands/pec_cmd.py',
str(cmd), pec_ip, '1', '0', '0', '0', '0'],
startupinfo=subprocess.STARTUPINFO(), env=os.environ,
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
稍后我将进程存储在一个字典中,该字典之前使用 subproccesses = {} 初始化:
subprocesses['process' + str(i)] = proc
任何想法或帮助为什么我得到这个 FileNotFoundError? 从 PyCharm 运行时,它可以工作,但是一旦创建了 exe(尝试了 --onedir 和 --onefile),它就会失败
【问题讨论】:
标签: python tkinter subprocess pyinstaller