I have a python script I run using Cygwin and I\'d like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in t
The simplest solution will be creating batch file containing command like:
c:\python27\python.exe c:\somescript.py
With this solution you will have to have installed python interpreter. If you need more portable solution you can try for e.g. py2exe and bundle python scripts into executable file, able to run without requiring a Python installation.
As an alternative to py2exe you could use the pyinstaller package with the onefile
flag. This is a solution which works for python 3.x.
install pyinstaller via pip
Package your file to a single exe with the onefile
flag
pyinstaller --onefile your_file.py
This tutorial shows how to create a batch file that runs a python script.
Note that many of the other answers are out of date - py2exe is out of support past python 3.4. More info here.
This comes straight from Python Docs (https://docs.python.org/3.3/using/windows.html):
3.3.5. Executing scripts without the Python launcher
Without the Python launcher installed, Python scripts (files with the extension .py) will be executed by python.exe by default. This executable opens a terminal, which stays open even if the program uses a GUI. If you do not want this to happen, use the extension .pyw which will cause the script to be executed by pythonw.exe by default (both executables are located in the top-level of your Python installation directory). This suppresses the terminal window on startup.
You can also make all .py scripts execute with pythonw.exe, setting this through the usual facilities, for example (might require administrative rights):
Launch a command prompt.
Associate the correct file group with .py scripts:
assoc .py=Python.File
Redirect all Python files to the new executable:
ftype Python.File=C:\Path\to\pythonw.exe "%1" %*