How To Run Python Programs On Windows And Linux

In the last article, we have discussed how to Install Python On Various operating systems. In this article, you will get to know how to run python programs in different ways.

Either Windows or Linux, be it any other operating system, running python programs is a very easy job. we can do this in two different and simple methods.

  • Running Python programs from idle or IDE itself
  • Running Python programs from Linux Shell or Windows cmd.

Running Python programs from Idle or IDE

In the last article, We have seen that some text editors are available which can do our task very easy. And, we have python idle and IDE (Ex: Pycharm) to write and run the programs from the IDE itself. For a typical IDE, we can hit the “RUN” button or F5 ( will be shown in IDE). It is the most preferable option in the community.

This image shows the typical Python IDE

pycharm-IDE-For-Python

Running Python Programs From Linux Shell And Windows Command Prompt

If you want to run the program from windows command prompt, You have to make sure a few things:

  • Added the python.exe to the path in environment variables.
  • Navigating to the directory from cmd to where your file is saved.

Now, you have to type as below where file.py is your filename in the command prompt.

Since Python 2.x has is taken as default interpreter in the Linux systems terminals, we have to specify the python3 while running python 3 code.

 

 

In the above image, it is clear that I have navigated to Desktop directory and took python3 as my interpreter to run the hello.py program.

Hope you have understood it clearly. If you are facing any issues or errors while running programs, don’t hesitate to ask me.

So far, We have discussed Introduction, Installing and Running python programs on Linux and Windows systems. And, the interesting stuff is ahead. So, please Keep reading and visiting our blog. Kindly give your remarks.

Leave a Reply

Your email address will not be published. Required fields are marked *