0
votes

It worked for me in the cmd.exe console:

C:\tools\python2-x86_32\Scripts\pyinstaller.exe --name="Name app" --onefile --windowed --icon=tk.ico script.py

But I need to compile python

This does not work:

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

','--name','Analysis log Pre-Alpha 1','--onefile ','--windowed','--icon=','tk.ico','tk.py']) File "C:\tools\python2-x86_32\lib\subprocess.py", line 522, in call return Popen(*popenargs, **kwargs).wait() 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 2]

This does not work:

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] 

How to make it work?

1
Can you try replacing 'Name app' with '"Name app"' - Tarun Behal
Error 5 corresponds to access denied. So can you try running your python script as administrator. - Tarun Behal
It does not change anything ( 'Name app' with '"Name app"' . - voice
I run my script in cmd.exe as administrator . It does not change anything - voice
Use a raw string: cmd = r'C:\tools\python2-x86_32\Scripts\pyinstaller.exe --name="Name app" --onefile --windowed --icon=tk.ico script.py'. The string literal '\t' is a tab character if you don't use a raw string. - Eryk Sun

1 Answers

0
votes

It works:

subprocess.call([r'C:\tools\python2-x86_32\Scripts\pyinstaller.exe','--name','Name app', '--onefile','--windowed','tk.py'])

Thanks Tarun Behal! Thanks eryksun!