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 the commands by hand. how can I do this?
6 Answers
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.

- 289
- 1
- 7
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" %*

- 190
- 2
- 5
-
Using pythonw.exe in the Windows shortcut worked perfectly for me, allowing the script to be run without the CMD window. Perfect! – Jason Etheridge Nov 25 '21 at 21:05
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.

- 705
- 7
- 23
A better way (in my opinion):
Create a shortcut:
Set the target to
%systemroot%\System32\cmd.exe /c "python C:\Users\MyUsername\Documents\MyScript.py"
Start In:
C:\Users\MyUsername\Documents\
Obviously change the path to the location of your script. May need to add escaped quotes if there is a space in it.

- 3,057
- 12
- 24
- 29

- 11
- 2
The solution that worked like a charm for me > From https://www.tutorialexample.com/convert-python-script-to-exe-using-auto-py-to-exe-library-python-tutorial/
pip install auto-py-to-exe
The GUI is available just by typing:
auto-py-to-exe
Then, I used this command to generate the desired output:
pyinstaller --noconfirm --onedir --windowed --icon "path/favicon.ico" "path/your_python_script"
Now I have my script as executable on taskbar

- 93
- 5