Long story short:
pythonw.exe does nothing,
python.exe accepts nothing (which one should I use?)
C:\path>pythonw.exe test.py <BLANK LINE> C:\path> C:\path>python.exe test.py File "C:\path\test.py", line 7 print "a" ^ SyntaxError: invalid syntax C:\path>
Please tell me what I'm doing terrible wrong.
If you don't want a terminal window to pop up when you run your program use
Regarding the syntax error:
So use instead:
To summarize and complement the existing answers:
python.exe is a console (terminal) application for launching CLI-type scripts.
python.exeopens a new console window.
sys.stderrare connected to the console window.
Execution is synchronous when launched from a
cmd.exe or PowerShell console window: See eryksun's 1st comment below.
pythonw.exe is a GUI app for launching GUI/no-UI-at-all scripts.
sys.stderrare NOT available.
print()can cause that to happen (in 3.x,
print()simply has no effect).
pythonw.exe yourScript.pyw 1>stdout.txt 2>stderr.txt
cmd /c pythonw.exe yourScript.pyw 1>stdout.txt 2>stderr.txt) to capture stdout and stderr output in files.
print()is the only reason your script fails silently with
pythonw.exe, and you're not interested in stdout output, use @handle's command from the comments:
pythonw.exe yourScript.pyw 1>NUL 2>&1
*.pywscripts directly (as opposed to by passing the script file path to
pythonw.exe). See eryksun's 2nd comment and its follow-ups below.
You can control which of the executables runs your script by default - such as when opened from Explorer - by choosing the right filename extension:
*.pyfiles are by default associated (invoked) with
*.pywfiles are by default associated (invoked) with