Sunday, November 5, 2017


Python runs on all major operating system. Any python code written should run on a computer with python installed on it.

Installing python on our systems may sometimes be complicated if we are not familiar with its installations. In order to enlighten us on how to install the python compiler and interpreter, this tutorial was brought up.
The method for setting and installing python on various operating system differs. Let check the installation on the various operating system.


Linux operating system are basically designed for programming, therefore, python is already embedded on most Linux computers. For this reason, there are few settings and few installations to be done.

To verify the version of python pre-installed on our Linux computer, open a terminal and type the word “python” in lowercase, you should see an output like this:

$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:38)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.   

The code snippets above show that python 2 is pre-installed on our Linux operating system as default. To check for python 3, we may have to specify the version, you can try this out:
$ python3

Python 3.5.0 (default, Sep 17 2015, 13:05:18)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.   

This output indicated that python 3 is also installed so we can use any of the version in executing our codes. Since we have python 3 installed, if we want to run our code, we will be using python 3.

After making sure we have python on our system, the next thing to do is to open up a text editor. I will suggest using Geany which can be installed through the terminal using the code below:

$ sudo apt-get install geany

After installing Geany, press the window key and search for Geany on your system. Drag it to your desktop or taskbar to create a shortcut.
Create a folder on your desktop where you will be saving your works so as not to mix it up with other documents on your system. Give the folder a name that describe the files it contains or its going to contain, in our own case, let name it python_practise.
Go back to Geany and type the following line of code:

print ("Hello world!")

save the file in the python_practise folder earlier created as Note: it is best to save a file with lowercase letters and an underscore where necessary as it is one of the best naming conventions.

After saving our work, it is time to compile and execute our code. If multiple version of python exists on our system, we need to specify to Geany, which version of python to use. Follow the instruction below to configure Geany to use python 3.

Build > Set Build Command  Change "compile" under "python commands" to "pytho3-mpy_compile "%f”
Change "execute" under the "execute commands" to "python3“%f”

Now let run our program. Go to Build -> Execute in the menu, on clicking the execute, a terminal windows should pop up and display:

Hello world!
(program exited with code: 0)
press return to continue

This shows that we have successfully configure our python 3 to run on Geany.

We can also run snippets of python code in a terminal session. Open a terminal and type the command python3, then type:

>>> print(“Hello world!)
Hello world!

The message would be printed directly in the terminal window. You can exit the python interpreter to go back to the normal terminal window by pressing CTRL + D or by typing exit().

That’s all about configuring and using python on Linux operating system. Stay updated with us as we bring to you how to install and configure python on OS X on the next episode of python tutorials. Thanks for reading and bye for now.


Post a Comment