What is IDLE?
IDLE stands for Integrated DeveLopment Environment. It is an IDE for Python, written in Python language itself and based on Tkinter with bindings to the Tk widget set. IDLE is most suitable for beginners as it has a simple IDE feature list. Hence, it is very popular in educational environments.
It is a cross-platform IDE solution that comes with a basic feature set that includes:
- Multi-window text editor with syntax highlighting, auto-completion, smart indent and other.
- Python shell with syntax highlighting.
- Integrated debugger with stepping, persistent breakpoints, and call stack visibility.
For more information on IDLE, visit the following official documentation:
In this article, we will be installing IDLE through the Ubuntu command line. The article also explains how to launch IDLE and use it to write and run a simple Python script.
We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system.
How to Install IDLE?
Python is installed by default on all the latest Ubuntu releases and it also usually comes with the IDLE application. However, if you have a minimal installation of Ubuntu that lacks any IDLE UI application, you can install it by following this method:
Open the Ubuntu command line, The Terminal, either through the system Dash or the Ctrl+Alt+T shortcut.
Then, you need to update your system’s repository index through the following command as sudo:
$ sudo apt-get update
This way your system’s repository gets in-line with the Internet repositories and that helps you in installing the latest version of any available software.
You need to run this command as sudo because only an authorized user can add/remove, update, and configure software on Ubuntu. The system will ask you the password for sudo and then execute the rest of the command when you have provided a correct password.
The next step is to run the following command in order to install IDLE3. This is the best-suited version when you have either Python 2 or Python 3 installed on your system.
$ sudo apt-get install idle3
The system might ask you for a Y/n input in order to make sure that you indeed want to install the software. Please enter Y and then hit Enter, after which IDLE3 will be installed on your system.
You can launch IDLE both through the command line or the Ubuntu UI.
Run the following command in the Terminal in order to launch IDLE.
Or else, enter keywords relevant to IDLE in your Ubuntu Dash search as follows:
This will list all the IDLE applications installed on your system. Click on any one of them to Launch the Python integrated development environment.
Your first Python program in IDLE
Open the IDLE application, which by default looks like this:
Your first line of code starts from where you see the three “greater than” or “>” symbols.
Place the cursor at this point and write or copy & paste the following line of code:
print("This is my first Python program :) :)")
This is a simple print statement that can be used to print anything inside the parentheses “( )”, on the screen.
When you hit Enter, the output is displayed as follows:
You can even choose to save the program (through the Save/Save As option from the File menu) and access it later (through the Open option from the File menu or directly by clicking it from where you have saved it).
After reading this article, you can integrate this Python development environment into your Ubuntu system and make the best use of its UI-based simple and easy to use feature set.