Site icon DesignLinux

How to Install and Use Thonny Python IDE on Linux

Thonny is an Integrated Development Environment (IDE) for Python beginners. It is created with Python and released under MIT License. It is cross-platform and can run in Linux, macOS, Windows.

Related Article: 10 Best Python IDEs for Linux Programmers in 2020

Why Thonny IDE

If you are new to programming or someone switching from a different language I suggest using thonny. The interface is clean and distraction-free. Newbies can concentrate on language instead of focusing on setting up the environment.

Some of the key features of thonny include

In this article, you will learn how to install and use Thonny Python IDE in a Linux environment and exploring the features of thonny.

Setting Up Thonny Python IDE on Linux

The latest version of Thonny is 3.3.0 and there are three ways you can install thonny in Linux.

Install Thonny IDE Using Pip

# pip3 install thonny

Install Thonny IDE Using Installer Script

# bash <(curl -s https://thonny.org/installer-for-linux)

Install Thonny IDE Using Package Manager

$ sudo apt install thonny   [On Debian/Ubuntu]
$ sudo dnf install thonny   [On CentOS/RHEL & Fedora]

For demonstration purposes, I am using Ubuntu 20.04 and running the installer script with wget command as shown above to install thonny. At the end of the installation, you will come to know where is thonny installed. In my case, it is installed in my home directory.

Thonny Installer

To launch thonny, go to the installed directory and type “./thonny” or absolute path to thonny. Thonny will ask you to set up Language and Initial settings.

Start Thonny IDE

As shown in the installation section, Thonny is installed in the home directory. If you look at the thonny folder it has install script, necessary python libraries for thonny to work, binaries. Inside the bin directory, there is python 3.7 and PIP 3 that comes with thonny and thonny launch binary.

Thonny Directory

How to Use Thonny IDE in Linux

When you launch Thonny you will get a distraction-free GUI interface. You will have an editor area where you can code and shell to run the script or test codes interactively.

Thonny IDE Editor

Linux distributions by default ships with python. Older version ships with Python2* and the latest versions ship with Python3*. We have already seen Python 3.7 is installed by default and thonny sets 3.7 as the default interpreter.

Thonny Python Shell

You can stick with the default interpreter (Python 3.7) or choose different interpreters available on the system. Go to “Menu BarToolsOptionsInterpreterSet the path” or “Menu BarRun → Select InterpreterSet the path”.

Set Thonny Python Interpreter

I suggest sticking with the default python installation unless you know how to fix it if something breaks when switching the interpreter.

Thonny comes with Light and Dark themes. You can change themes for Editor as well as UI theme. To change Theme and Fonts Go to “Menu BarToolsOptionsTheme & Font”.

Thonny IDE Theme

There are 3 ways you can run the code you created. First, your code should be saved to a file for Thonny to execute.

The first two methods will switch the directory to wherever your code is and invoke the program file in the Built-in terminal.

Run Programe in Thonny Terminal

The third option allows you to run your code in an external terminal.

Run Programe in External Terminal

The real power of thonny comes with built-in features like File Explorer, Variable Explorer, Shell, Assistant, Notes, Heap, Outline, Stack. To Toggle on-off these features Go to “View → toggle Feature ON/OFF”.

Thonny Build-in Features

Thonny Package Manager

It is known that all the python packages are hosted at PyPI. We will normally use PIP (Python Package Manager) to install desired packages from PyPI. But with Thonny, a GUI interface is available to manage packages.

Go to “Menu BarToolsPackages”. In the search bar, you can type a package name and press search. It will search the PyPI index and displays the list of package matching the name.

In my case, I am trying to install a package call numpy.

Search Package in Thonny

When you select the package from the list, It will take you to the installation page. You can install the latest version or choose different versions as shown in the image. Dependencies are automatically installed.

Select Package Version

Once you press Install, it will install the package.

Install Package in Thonny

You can get the details like package version, library location once the package is installed. In case if you wish to uninstall the package, it is simple, go ahead and click the “uninstall” button at the bottom of the package as shown in the image.

Package Details

Thonny Debugging

Thonny comes with a built-in debugger. Press Ctrl+F5 to run your program step-by-step, no breakpoints needed. Press F7 for a small step and F6 for a bigger step. You can also access these option from “Menu BarRunDebugging options”.

Thonny Debugger

Thonny Configuration

All the configurations are stored in the “configuration.ini” file. Any changes you make with your thonny session is written to this file. You can also manually edit this file to set different parameters.

To open the file go to “Menu BarToolsOpen Thonny data folder”.

Thonny Configuration File

How to Uninstall Thonny IDE in Linux

If you wish to uninstall thonny, there is an uninstall script available under the thonny installation directory.

$ /home/tecmint/apps/thonny/bin/uninstall   [Installed using Script]
$ pip3 uninstall thonny                     [If Installed using PIP]
$ sudo apt install thonny                   [On Debian/Ubuntu]
$ sudo dnf install thonny                   [On CentOS/RHEL & Fedora]

That’s it for this article. There is a lot more to explore in Thonny than what we discussed here. Thonny is great for beginners but it is always a personal choice of programmers to choose which IDE or Text editor to work with. Install Thonny play with it, share your feedback with us.

Exit mobile version