Getting Started with Python IDLE

Python is popular programming and scripting language used by a lot of people. There are a lot of tools and software in order to develop python scripts and applications.

What Is Python IDLE?

IDLE is the short form of the Integrated Development and Learning Environment . IDLE is a simple IDE (Integrated Development Environment) which do not provides full features of IDE. But IDLE provides basic features in order to start learning and development of the Python programming language. Python IDLE is created and developed by the Python Programming Language community. So Python IDLE has been first provided with the Python version 1.5 which is a long time ago. As a not core tool it is provided optionally which is not installed default with Python but can be installed easily simple steps.

As a simple and basic IDE Python IDLE provides less features than other Python IDE’s. Following features are provided by Python IDLE to make the Python development and test easier.

  • Cross-platform where operating systems like Windows, Linux, Ubuntu, MacOS supported
  • Created and coded with Python where GUI uses the tkinter library.
  • Provides interactive Python shell same as Python command line shell.
  • Code is colorized according to the Python syntax
  • Multiple windows can be opened and used at the same time
  • Smart indent provided to automatically indent Python code blocks
  • Provides auto completion for keywords, variables, modules etc.
  • Useful search and replace features in a single or multiple windows and files
  • Debugging the script to detect errors, exceptions easily by using breakpoints, stepping

Install Python IDLE For Ubuntu, Debian, Mint

IDLE is provided as a package in deb based distributions like Ubuntu, Debian, Mint etc. In order to install and run IDLE the Python should be installed but during the installation of the IDLE if the Python is not installed it will be installed automatically. Python has two major version called as Python2 and Python3. Two IDLE installation package is provides for these version.

IDLE for Python3 can be installed with the package named idle-python3.8 like below. But keep in mind that if the Python version changes to the 3.9 the package name may be changing too.

$ sudo apt install idle-python3.8

IDLE for Python2 can be installed with the package named idle-python2.7 like below.

$ sudo apt install idle-python2.7

Python IDLE can be started from the application menu or command line. Application menu can provide different categories but for XFCE desktop the Development Tools contains the IDLE.

We can also start IDLE from the Linux bash or command line by using the idle-python3.8 command like below. But this will start Python 3 IDLE.

$ idle-python3.8

If you have installed the Python2 IDLE you should use the idle-python2.7 command from the Linux bash or command line like below.

$ idle-python2.7

You can see that then we start IDLE a Python shell is provided on the main screen. Also, some information like Python Interpreter, Build Date, Build Tool, and Help information about the IDLE is provided automatically by default.

Install Python IDLE For Windows

IDLE for windows is provided with the Python installation executable. In order to install Python IDLE on windows during the installation of the Python the tcl/tk and IDLE feature should be selected like below.

https://www.python.org/downloads/

https://www.python.org/downloads/release/python-385/

You can access the IDLE from the start menu or program files by typing its name like below.

Install Python IDLE For MacOS

Python IDLE can be installed for MacOS similarto the Windows operating systems. Python installation will provides the IDLE as a features which can be installed easily. Following link provides Python3.8 MacOS 64-bit installer in pkg format. This setup file work with OS X 10.9 and later versions. If you need to install older versions take look for older Python versions like Python3.7, Python3.6 etc.

https://www.python.org/downloads/release/python-385/

Print IDLE Version Information

In order to print the IDLE version and related information the Help-> About IDLE menu can be used. About IDLE will provide information for the IDLE installation, Python interpreter version, email for support, Tk version, copyright information tec.

Run Python Script with IDLE Interactive Shell

The IDLE main screen provides the python shell which is like an MS-DOS or Linux Bash shell. We can run simple or complex Python scripts from this shell but if you want to develop applications prefer the Python files which will be described below. We will run the following Python print() function in the IDLE interactive shell.

print("Hello Wisetut.com")

We can see that the script will output to the current interactive shell. This is very useful to test simple scripts or code.

Create a Python Script File

We can create a new script file from the File->New File menu from the menu bar. Alternatively we can use the CTRL+N keyboard shortcut to create a new script file directly.

We will see the following screen which is like a simple text editor with more menu items. We can put the script or code we want to create into the file like below.

In order to create a new file, we will save from the File->Save menu or use the CTRL+S keyboard shortcut like below. We will be asked the filename we want to save where the file extension will be *.py by default.

Run Python Script File

We can run a Python file by using the Run->Run Module steps from the IDLE menu. Alternatively, you can use the F5 keyboard shortcut. Running a python script file will create a new interactive shell and execute the Python script file content.

When the script is executed you will see a screen like this where the executed script full path and name printed to the interactive shell and the script outputs will be printed to the screen.

Opening Python Script File

You can open a Python Script file with IDLE by using the File->Open steps from the menu. Alternatively, you can use the CTRL+O keyboard short cut to open the file menu.

Open Python Script File

We can navigate to the Python file we want to open in the IDLE and selecting the file. This open file menu will only show the Python files which are configured right bottom corner. Python files may have an extension like .py .py2 or .py3 .

Select Python Script to Open

After clicking to the Open the selected python file will be opened in the current editor.

Leave a Comment