Thursday, August 18, 2016

How to install Python on Lubuntu 16.04?


When learning python for the first time, you probably asking how to install python on lubuntu/ubuntu? the truth is python interpreter is already exist on your system.

Since lubuntu/ubuntu 14.04, python comes pre-installed, so you don't need to install anything, it's already there on your operating system waiting for your command.

To prove it, you can go ahead open terminal/ console/ command line (press CTRL + ALT + T) and then run this command :

python -V
python3 -V
*NOTE : the v is capital letter.

There actually two version of python on your system, the first one is python version 2 (python) and the second is python version 3 (python3), it is up to you which one you want to use.


Text editor for python
Now that you have python on your operating system, next thing to do is getting a good text editor for python. Well of course you can use any text editor, but wouldn't be great if you have built in python shell inside the editor?

One great text editor for python is IDLE, this text editor is highly recommended for python beginner's, it's a great text editor, have built in python shell and easy to use.

Unfortunately IDLE does not come pre-installed on lubuntu/ubuntu, but you can install IDLE using this command:

sudo apt-get install idle

Creating your first python "hello world" program
Usually when some one learn new programming language, the first thing they do is creating a hello world program, so let's create hello world program in python.

Create a file called helloworld.py using any text editor, you can use leafpad, gedit, sublime or IDLE, if using IDLE press CTRL + N to open new file and then save it as helloworld.py.

inside helloworld.py, type this simple code:

print("Hello World")

Save it and then run from command line like this (or simply hit F5 on your keyboard if you are using IDLE as text editor) :

python helloworld.py

That's it, congratulation man, you just create your first python program.

No comments:

Post a Comment