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)
#1
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?
Reply
#2
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.
Pedroski55 likes this post
Reply
#3
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
Pedroski55 likes this post
My code examples are always for Python >=3.6.0
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to make a Vocal synthesizer program on Python? Seadust 3 721 Jan-28-2021, 06:26 PM
Last Post: gonnach
Bug Python Shell 3.9.0 - Issue with indentation Earis 17 1,677 Oct-31-2020, 07:00 AM
Last Post: Earis
  I try to make Heron formula program abcd 7 708 Oct-22-2020, 12:48 AM
Last Post: abcd
  Make a Python program executable in Windows Pedroski55 1 565 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,013 Apr-18-2020, 10:05 AM
Last Post: Shahmadhur13
  Python "Terminal" vs "Shell" SectionProperties 2 1,009 Apr-10-2020, 08:36 AM
Last Post: SectionProperties
  how to make a program with a certain number of multiples? syafiq14 3 919 Jan-01-2020, 02:39 PM
Last Post: syafiq14
  python shell teelado 1 861 Jun-13-2019, 01:49 AM
Last Post: Larz60+
  How to make a program run "online"? DanielTkach 2 1,026 Apr-09-2019, 11:59 PM
Last Post: DanielTkach
  Is it possible to have my python shell change the backgrounds colour? OTO1012 2 1,619 Mar-07-2019, 09:32 PM
Last Post: woooee

Forum Jump:

User Panel Messages

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