Python Forum
How to make a Python program run in a dos shell (cmd)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a Python program run in a dos shell (cmd)
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.
Pedroski55 likes this post
Better is to use the installed py.exe which finds the latest installed (or configured) Python Interpreter on the System (also localappdata).
Pedroski55 likes this post
My code examples are always for Python >=3.6.0
Almost dead, but too lazy to die:
All humans together. We don't need politicians!

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to make a Vocal synthesizer program on Python? Seadust 3 974 Jan-28-2021, 06:26 PM
Last Post: gonnach
Bug Python Shell 3.9.0 - Issue with indentation Earis 17 1,945 Oct-31-2020, 07:00 AM
Last Post: Earis
  I try to make Heron formula program abcd 7 845 Oct-22-2020, 12:48 AM
Last Post: abcd
  Make a Python program executable in Windows Pedroski55 1 657 Sep-26-2020, 12:34 AM
Last Post: bowlofred
  I code a program to solve puzzle but i can't make it more dynamic. Shahmadhur13 5 1,130 Apr-18-2020, 10:05 AM
Last Post: Shahmadhur13
  Python "Terminal" vs "Shell" SectionProperties 2 1,122 Apr-10-2020, 08:36 AM
Last Post: SectionProperties
  how to make a program with a certain number of multiples? syafiq14 3 1,065 Jan-01-2020, 02:39 PM
Last Post: syafiq14
  python shell teelado 1 949 Jun-13-2019, 01:49 AM
Last Post: Larz60+
  How to make a program run "online"? DanielTkach 2 1,119 Apr-09-2019, 11:59 PM
Last Post: DanielTkach
  Is it possible to have my python shell change the backgrounds colour? OTO1012 2 1,756 Mar-07-2019, 09:32 PM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020