Question:
How to execute programs on python? Using the Command Prompt?
Matt
2011-06-19 13:32:40 UTC
I just started programming yesterday. Today, I started using the script. I put my code in for the program and saved it. When I open it, it goes back to the script instead of executing the program. How do I get it to execute the program instead of just going back to the script? I can run the script on IDLE but am unable to run it on the command prompt.

Thanks a ton.
PS- Python 3.1

how do i get my script to execute in the command prompt?
Four answers:
Oliver
2011-06-19 15:03:46 UTC
Use py2exe.py to create a windows executable (.exe) from your script. Its available here: http://www.py2exe.org/index.cgi/Tutorial

Otherwise this should execute from the cmd-line as C:\python {program} but if the path isn't resolved it won't be able to run the interpreter. sometime python isn't called python, its called python26 or python27.

So you would have to type C:\python26 {program}.



You can set python to be in your PATH environmental variable using properties, right click 'my computer' in start menu.

.
Ben
2011-06-19 13:35:23 UTC
If Python is on your path, then you can just type "python yourscript.py". If it's not on the path, you'll have to specify the path to the executable yourself, for example "C:\Python31\python yourscript.py"
bautista
2016-11-11 05:33:45 UTC
i'm attempting to reset teh rearm anticipate my (specific) official living house windows replica basically reason i'm doing it this way is I used all 50! yeah keys already... i like to reformat while something vegetation up :P enormous deal.
Dj
2011-06-20 10:18:33 UTC
it is probably already running it, just exiting out after it is done.



try this at the end of your script:

exita = input("Exit")


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...