Python Forum
How to make a Python program run in a dos shell (cmd) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to make a Python program run in a dos shell (cmd) (/thread-30835.html)



How to make a Python program run in a dos shell (cmd) - Pedroski55 - Nov-09-2020

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?


RE: How to make a Python program run in a dos shell (cmd) - ndc85430 - Nov-09-2020

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 foo.py, python foo.py should work.


RE: How to make a Python program run in a dos shell (cmd) - DeaD_EyE - Nov-09-2020

Better is to use the installed py.exe which finds the latest installed (or configured) Python Interpreter on the System (also localappdata).

https://docs.python.org/3/using/windows.html