它在cmd.exe控制台中对我有用:
C:\tools\python2-x86_32\Scripts\pyinstaller.exe --name="Name app" --onefile --windowed --icon=tk.ico script.py
但我需要编译python
这不起作用:
subprocess.call(['C:\tools\python2-x86_32\Scripts\pyinstaller.exe ','--name','Name app','--onefile ','--windowed','--icon=','tk.ico','script.py'])
Traceback (most recent call last): File "C:/Users/usercom/Documents/sql_alpha/sqlms.py", line 96, in <module> subprocess.call(['C:\tools\python2-x86_32\Scripts\pyinstaller.exe
&#39;,&#39; - 名称&#39;,&#39;分析日志Pre-Alpha 1&#39;,&#39; - onefile &#39;&#39; - 窗&#39;,&#39; - 图标=&#39;&#39; tk.ico&#39;&#39; tk.py&#39; ]) 文件&#34; C:\ tools \ python2-x86_32 \ lib \ subprocess.py&#34;,第522行,正在通话中 返回Popen(* popenargs,** kwargs).wait() 文件&#34; C:\ tools \ python2-x86_32 \ lib \ subprocess.py&#34;,第710行, init errread,errwrite) 文件&#34; C:\ tools \ python2-x86_32 \ lib \ subprocess.py&#34;,第958行,在_execute_child中 STARTUPINFO) WindowsError:[错误2]
这不起作用:
cmd = 'C:\tools\python2-x86_32\Scripts\pyinstaller.exe --name="Name app" --onefile --windowed --icon=tk.ico script.py'
subprocess.Popen(cmd, stdout=subprocess.PIPE)
> Traceback (most recent call last): File "C:/Users/usercom/Documents/sql_alpha/sqlms.py", line 97, in <module> subprocess.Popen(cmd, stdout=subprocess.PIPE) File "C:\tools\python2-x86_32\lib\subprocess.py", line 710, in __init__ errread, errwrite) File "C:\tools\python2-x86_32\lib\subprocess.py", line 958, in _execute_child startupinfo)
WindowsError: [Error 5]
如何让它发挥作用?
答案 0 :(得分:0)
有效:
subprocess.call([r'C:\tools\python2-x86_32\Scripts\pyinstaller.exe','--name','Name app', '--onefile','--windowed','tk.py'])
谢谢Tarun Behal! 谢谢eryksun!