Python Forum

Full Version: How to make a Python program run in a dos shell (cmd)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am not used to Widows. I run my little Python programs in bash.

To do that, I have to put:

Quote:#! /usr/bin/python3

as the first line of my program. I think this is called the "shebang".

A girl asked me to help her install Python on Windows.

If she now makes any little programs, how can she run them in the dos shell (cmd) in Windows??

Does she need a shebang?

In Linux, I have to explicitly make any programs executable before I can run any programs in bash.

Does Windows need that?
Well, no, you don't really have to use the shebang even on Linux. On both systems you can just run the script with python (or python3 if that's what the executable is called), i.e. if your script is, python should work.
Better is to use the installed py.exe which finds the latest installed (or configured) Python Interpreter on the System (also localappdata).