How ToUncategorized

How To Run Python Script In Linux Complete Guide

If you are from the programming field, you can relate to the thing that “Python is not a language, Python is a lifestyle” and well this is the most accurate thing we have heard about this language so far. Everyone ships Pythons and everyone wants to learn it.

Python scripts are more like text files and can be edited on the simple and in-built text program of the operating system. You can use any text editor program according to your operating system because not all operating systems support the same text editor programs. However, while choosing the text editor for the Python scripts, make sure it has been equipped with syntax highlighting. Coming to the point, we have made the article to tell you about the process of How To Run Python Script In Linux in a complete guide. So, have a look!

Hello World! Is the most common programs that beginner python users write and at the end of this program, you will get to see the “Hello, World!” phrase and after some time, it will be terminated. This is basically to teach the users how to run python scripts using text editors.

You May Also Check:

Step 1 – Starting Off

  1. In the first step, open the text editor software and create a new file with “” as a file name and add “print (‘Hello, World!’)” in it. If you are using the Python 3.x.x, you can write “print (“Hello, World!”)”.
  2. It allows the users to add the pausing factor if you type in “input ()” in the text editor. It also uses a print function which helps output the parameters to the assigned terminals. The print function adds a newline character to the output which will navigate the cursor to the net line

Step 2 – Running Python In Linux

The process for running python scripts varies for every operating system and as our article is about Linux, we have added how to run python scripts in Linux, so have a look!

  1. First of all, create the new folder with /pythonpractice and save it and then add then program in it
  2. Now, open the terminal program
  3. Now, open the KDE, open the main menu and run command in Konsole (If you don’t know how to open Konsole, open the main menu in GNOME and go to the applications folder. Then, open the accessories folder and choose the terminal)
  4. Type in cd ~/pythonpractice and hit the enter button
  5. You will have to make sure that script has been made executable by chmod +x
  6. Now, type in python./ and the python script will be run!

Important Note: If the python version is 2.6.1 or python 3.0, run python3

Step 3 – Running Python In Linux Advanced

  1. In this first step, create the folder with ~/pythonpractice
  2. Now, open the text editor program and create a new file with the name “” which will have following two lines;

#! /usr/bin/python

print(‘Hello, world!’)

  1. Save the file in the /pythonpractice folder
  2. Now, open the terminal program and open the main menu through KDE to run the command
  3. Type cd~/pythonpractice and hit enter
  4. Now, add the chmoda+x in order to communicate that the file is executable in Linux
  5. Now, just type in ./ to run the program

The result of both step 2 and step 3 has to be “Hello, World!” and we hope that this is the result that you achieved. If you have any more questions, reach out to us in the comment section below and we will be here to help. If you like the information, share it with your python lover friends and help us grow. Thank you!

Related Articles

Leave a Reply

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

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker