Start the script with with pythonw
instead of python
to avoid the shell showing up. This actually applies to Python 2.x
and 3.x
.
See pythonw.exe or python.exe?
If you would like to start the script by double clicking the file you can associate the file extension to be opened with pythonw.exe
instead of python.exe
. This will apply to all your *.py
files!
Rightlick run.py
, Open with
, Choose another app
, More apps
, Look for another app on this PC
. Locate your pythonw.exe
- it's next to your python.exe
. Then check the checkbox Always use this app to open .py files
.
To avoid associating this behaviour with all your *.py
files, change the extension of run.py
to e.g .pyw
and then apply the described steps.
If you don't know where your python.exe
is but you can use it from the terminal then open PowerShell and enter (Get-Command pythonw.exe).Source
to find out.
This only applies to your computer - if you want this to work on all machines you copy your file to, please see Fabrizios answer.