How to run Python
If you are using command prompt, instead of integrated development environment, open the cmd.
In Python, our Python scripts have to be processed by another program called the Python interpreter. The interpreter reads your script, compiles it into bytecodes, and then executes the bytecodes to run your program.
We can start the interpreter by typing py in the cmd. Now you are the interpreter is the interactive mode.
If you got a screen similar to the above, then know that the py
command is recognized, now you can give your Python script to it. You’ll have to give either an absolute or a relative path to the Python script. Consider your Python script is located in your desktop and is named test.py
, navigate to that folder using cd
.
Now type py test.py