Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Python in cmd [duplicate]

I am running python 2.7, I can run a program fine when I open the *.py file.

But when I go to cmd and type "python *.py any other args", it doesn't work, it says that python is not recognised. This is hard because I am trying to do things like sys.argv[], any help is great.

Thanks

like image 381
Angus Moore Avatar asked Jun 13 '12 23:06

Angus Moore


People also ask

How do I run Python from CMD?

To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World! If everything works okay, after you press Enter , you'll see the phrase Hello World!

How do I run a different version of Python from the command line?

The default Python interpreter is referenced on Windows using the command py. Using the Command Prompt, you can use the -V option to print out the version. You can also specify the version of Python you'd like to run. For Windows, you can just provide an option like -2.7 to run version 2.7.


1 Answers

You can solve this creating a bat file contenting:

cd %USERPROFILE%\AppData\Local\Programs\Python\Python37-32
cls
.\python

Then, you save on C:\Windows\System32 as python.bat

like image 183
Eduardo Lôbo Avatar answered Oct 05 '22 18:10

Eduardo Lôbo