In this article, I will show you how to install Python 3.6 and Python 3.7 in case you don’t have it installed. Let’s get started.
Installing Python 3
First update the package repository cache with the following command:
The package repository cache should be updated.
Installing Python 3.6:
Now to install Python 3.6, run the following command:
As you can see from the screenshot below, Python 3.6 is already installed as I said.
Installing Python 3.7:
To install Python 3.7 (still in beta at the time of this writing), run the following command:
Press y and then press <Enter>.
Python 3.7 should be installed.
You can run the following command to verify whether Python 3.7 is working:
As you can see, it’s working.
Installing Python 3 IDLE for Developing Python Program
Python 3 IDLE is a graphical program for writing python 3 programs and test them. It is beginner friendly. You can always start writing Python 3 code with Python 3 IDLE. It is lightweight and has nice syntax highlighting ability.
Python 3 IDLE is available in the official package repository of Ubuntu 18.04 LTS.
For Python 3.6:
To install Python 3 IDLE for Python 3.6, run the following command:
Press y and then press <Enter> to continue.
It should be installed.
For Python 3.7:
To install Python 3 IDLE for Python 3.7, run the following command:
Using IDLE to Develop a Python 3 Program
Now that you have Python 3 IDLE installed, you can go to the Application Menu and search for Python 3 IDLE.
You should see the following icon as marked in the screenshot below, click on it.
You should see the following window. This is a Python 3.6 shell where you can execute python codes, one line at a time. It is good for testing very simple codes or logics before putting it to your Python 3 source code file.
Now to go to the graphical editor, click on File and you should see the following menu. From here you can click on Open… to open an existing Python 3 source code file in the graphical editor.
NOTE: You can also press <Ctrl> + o to open an existing Python 3 source file in the graphical editor.
Or you can click on New File… to create a new file and open it in the graphical editor.
NOTE: You can also press <Ctrl> + n to create a new file and open it in the graphical editor.
I created a new file, and when you do, it should look something like this. This is the graphical code editor.
Once you write some code in it, save it somewhere on your filesystem. To save the file, click on File and then click on Save as shown in the screenshot below.
NOTE: You can also save the file by pressing <Ctrl> + s.
Now let’s write our very first Python 3 program and save it as hello.py somewhere on your filesystem.
To run the program, click on Run and then click on Run Module. You can also press F5 to run the program.
As you can see, the correct output is displayed on the console.
Customizing Python 3 IDLE
You can go to Options and then Configure IDLE to go to the configuration window of Python 3 IDLE.
Settings window should open as you can see in the screenshot below. From the Fonts/Tabs tab, you can change your IDLE font, font size, the default indentation width.
From the Highlights tab, you can change the Color Scheme or Theme of IDLE. By default, IDLE Classic is set. You can also choose IDLE Dark and IDLE New as you can see in the marked section of the screenshot below.
Once you’re done, click on OK. The changes should be applied.
IDLE Dark theme:
That’s how you install Python 3 and start learning Python 3 on Ubuntu 18.04 LTS. Thanks for reading this article.