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
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
  Help creating shell scrip for python file marciokoko 10 1,262 Sep-16-2023, 09:46 PM
Last Post: snippsat
  Launch Python IDLE Shell from terminal Pavel_47 5 1,143 Feb-17-2023, 02:53 PM
Last Post: Pavel_47
  Can a program execute code in iPython shell and get result? deanhystad 3 1,664 Jun-17-2022, 03:45 AM
Last Post: Larz60+
  Is it possible to make a program recognize how many clicks it has had on the monitor? jao 0 1,129 Feb-25-2022, 06:31 PM
Last Post: jao
  batch file for running python scipt in Windows shell MaartenRo 2 1,825 Jan-21-2022, 02:36 PM
Last Post: MaartenRo
  What do i have to type in the IDLE shell to use this password manager program? MaartenRo 4 1,691 Jan-15-2022, 02:01 PM
Last Post: MaartenRo
  How to make a Vocal synthesizer program on Python? Seadust 3 3,491 Jan-28-2021, 06:26 PM
Last Post: gonnach
Bug Python Shell 3.9.0 - Issue with indentation Earis 17 6,438 Oct-31-2020, 07:00 AM
Last Post: Earis
  I try to make Heron formula program abcd 7 3,329 Oct-22-2020, 12:48 AM
Last Post: abcd
  Make a Python program executable in Windows Pedroski55 1 2,068 Sep-26-2020, 12:34 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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