Thonny：在学校教授 Python 编程的理想 IDE
Python
![](/data/attachment/album/202206/16/133337sllc9me9jeqjeuuc.jpg)


在 Linux 中运行一个 Python 程序只需要简单地在终端中执行 Python 文件就行。


但这对人们来说不是很方便，也不能帮助你调试你的程序。太原始了。


有几个 IDE 和文本编辑器可以用于 Python 开发。Linux 用户可以使用 [PyCharm 社区版](https://itsfoss.com/install-pycharm-ubuntu/)。


我最近发现了另一个专门为 Python 初学者制作的 IDE。我喜欢这个应用的想法，因此我在这里与你分享。


### Thonny 是一个跨平台、开源的 Python IDE，适合初学者使用


[Thonny](https://thonny.org/) 在用户界面和用户体验方面，感觉就像 Python 版本的 Eclipse。考虑到大多数 C++ 和 Java 的初学者都是从 Eclipse 开始的，而且许多人后来一直使用它，这也不完全是一件坏事。


它不是一个新的工具。它已经出现好几年了。我没有用 Python 进行编码，所以直到最近才发现它。


Thonny 专注于 Python，提供了帮助 Python 初学者了解其程序行为的功能。让我们来看看这些功能。


#### 即装即用


Thonny 自带 Python，所以你不需要为安装 Python 做额外的努力。这对 Linux 用户来说不是什么大事，因为大多数发行版都默认安装了 Python。


界面很简单。它给你一个编辑器，你可以写你的 Python 程序，然后点击运行按钮或使用 `F5` 键来运行程序。输出显示在底部。


![thonny hello world](/data/attachment/album/202206/16/133356mwdqan7hu8rzhn89.png)


#### 查看变量


在 “<ruby> 查看 <rt>  View </rt></ruby>-><ruby> 变量 <rt>  Variables </rt></ruby>”，你可以看到所有变量的值。不需要将它们全部打印出来。


![thonny variable pane](/data/attachment/album/202206/16/133357sdp1aa2zn3d6lpn2.png)


#### 内置调试器


通过使用调试器一步步运行你的程序。你可以从顶部的菜单或使用 `Ctrl + F5` 键访问它。在这里你甚至不需要设置断点。你可以用 `F6` 进入大步骤，或用 `F7` 进入小步骤。


![thonny step by step f6](/data/attachment/album/202206/16/133357l606x7oq69syx6xi.png)


在小步骤中，你可以看到 Python 是如何看待你的表达式的。这对新的程序员理解他们的程序为什么以某种方式表现非常有帮助。


![thonny step by step f7](/data/attachment/album/202206/16/133357o9sf8xfg60rp8cpg.png)


不止这样。对于函数调用，它会打开一个新的窗口，里面有独立的局部变量表和代码指针。超级酷!


#### 语法错误高亮


初学者经常会犯一些简单的语法错误，如缺少小括号、引号等。Thonny 会在编辑器中立即指出来。


本地变量也可以从视觉上与全局变量区分开来。


#### 自动补全


你不需要输入所有的东西。Thonny 支持自动补全代码，这有助于加快编码。


![thonny auto complete](/data/attachment/album/202206/16/133358wc72o1vbq7tf678b.png)


#### 访问系统 shell


在工具中，你可以访问系统 shell。在这里你可以安装新的 Python 包或学习从命令行处理 Python。


![thonny shell terminal](/data/attachment/album/202206/16/133358vttln57iw3iajxjj.png)


请注意，如果你使用 Flatpak 或 Snap，Thonny 可能无法访问系统 shell。


#### 从 GUI 管理 Pip


进入工具和管理包。它会打开一个窗口，你可以从这个 GUI 中安装 Pip 软件包。


![thonny manage packages](/data/attachment/album/202206/16/133359bqn3ndppd1uwlj3j.png)


对于学习 Python 来说，功能足够好，对吗？让我们看看如何安装它。


### 在 Linux 上安装 Thonny


Thonny 是一个跨平台的应用。它可用于 Windows、macOS 和 Linux。


它是一个流行的应用，你可以在大多数 Linux 发行版的仓库中找到它。只要在你的系统的软件中心寻找它。


另外，你也可以随时使用你的 Linux 发行版的包管理器。


在 Debian 和基于 Ubuntu 的发行版上，你可以使用 `apt` 命令来安装它。



```
sudo apt install thonny

```

它会下载一堆依赖关系和大约 300MB 的软件包。


安装后，你可以在菜单中搜索它，并从那里安装它。


### 总结


Thonny 对于初级 Python 程序员来说是个不错的工具。不是说专家不能使用它，但它更适合在学校和学院使用。学生们会发现它有助于学习 Python 和理解他们的代码是如何以某种方式表现出来的。事实上，它最初是在爱沙尼亚的塔尔图大学开发的。


总的来说，对于 Python 学习者来说是一个很好的软件。




---


via: <https://itsfoss.com/thonny-python-ide/>


作者：[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题：[lkxed](https://github.com/lkxed) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

Running a Python program in Linux is as simple as executing the Python file in the terminal.

But that’s not very convenient for everyone and it doesn’t help you debug your programs. Too raw.

There are several IDEs and text editors that can be used for Python development. The [PyCharm community edition is available for Linux users](https://itsfoss.com/install-pycharm-ubuntu/).

I recently came across another IDE specifically crafted for Python beginners. I liked the idea of this application and hence I am sharing it with you here.

## Thonny is a cross-platform, open source Python IDE for beginners

[Thonny](https://thonny.org/?ref=itsfoss.com) feels like the Python version of Eclipse in terms of UI and UX. And that’s not entirely a bad thing considering most C++ and Java beginners start with Eclipse and many stay with it afterward.

It’s not a new tool. It has been on the horizon for some years now. I don’t code in Python so I never discovered it until recently.

Dedicated to Python, Thonny has features that help Python beginners understand how their program behaves. Let’s take a look at those features.

### Plug and play

Thonny comes with Python so you don’t need to do additional effort for installing Python. That’s not a big deal for Linux users as most distributions have Python installed by default.

The interface is simple. It gives you an editor where you can write your Python program and hit the Run button or use F5 key to play the program. The output is displayed at the bottom.

![thonny hello world](https://itsfoss.com/content/images/wordpress/2022/06/thonny-hello-world.png)

### See variables

From the View->Variables, you can see the values of all the variables. No need to print them all.

![thonny variable pane](https://itsfoss.com/content/images/wordpress/2022/06/thonny-variable-pane.png)

### Built-in debugger

Run your program step by step by using the debugger. You can access it from the top menu or use the Ctrl+F5 keys. You don’t even need the breakpoints here. You can go into big steps with F6 or in small steps with F7.

![thonny step by step f6](https://itsfoss.com/content/images/wordpress/2022/06/thonny-step-by-step-f6.png)

In small steps, you can see how Python sees your expressions. This is very helpful for new programmers to understand why their program is behaving in a certain manner.

![thonny step by step f7](https://itsfoss.com/content/images/wordpress/2022/06/thonny-step-by-step-f7.png)

That’s not it. For function calls, it opens a new window with separate local variables table and code pointer. Super cool!

### Syntax error highlighter

Beginners often make simple syntax errors like missing paranthesis, quotes etc. Thonny is points it out immediately in the editor itself.

Local variables are also visually distinguished from globals.

### Auto completion

You don’t have to type everything. Thonny supports auto code completion which helps in coding faster.

![thonny auto complete](https://itsfoss.com/content/images/wordpress/2022/06/thonny-auto-complete.png)

### Access to system shell

From the Tools, you can access the system shell. From here you can install new Python package or learn to handle Python from the command line.

![thonny shell terminal](https://itsfoss.com/content/images/wordpress/2022/06/thonny-shell-terminal.png)

Please note that if you use Flatpak or Snap, Thonny may not be able to access the system shell.

### Manage Pip from GUI

Go to Tools and Manage packages. It opens a window and you can install Pip packages from this GUI.

![thonny manage packages](https://itsfoss.com/content/images/wordpress/2022/06/thonny-manage-packages.png)

Good enough features for learning Python, right? Let’s see how to install it.

## Installing Thonny on Linux

Thonny is a cross-platform application. It is available for Windows, macOS and Linux.

It’s a popular application and you can find it in the repositories of most Linux distributions. Just look for it in your system’s software center.

Alternatively, you can always use the package manager of your Linux distribution.

On Debian and Ubuntu-based distributions, you can use the apt command to install it.

`sudo apt install thonny`


It downloads a bunch of dependencies and around 300 MB of packages.

Once installed, you can search for it in the menu and install it from there.

## Conclusion

There are plenty of other [Python IDEs available for Linux](https://itsfoss.com/best-python-ides-linux/).

[7 Best Python IDEs for Ubuntu LinuxLooking to code Python on your Linux system? Here are the best IDEs you can use for Python programming in Linux desktop.](https://itsfoss.com/best-python-ides-linux/)![](https://itsfoss.com/content/images/wordpress/2022/11/foss-python-ides-for-linux.png)


![](https://itsfoss.com/content/images/wordpress/2022/11/foss-python-ides-for-linux.png)

Thonny is a decent tool for beginner Python programmers. Not that experts cannot use it but it’s more suited to be used in schools and colleges.

Students will find it helpful in learning Python and understanding how their code behaves in a certain manner. In fact, it was originally developed in the University of Tartu, Estonia.

Overall, good software for Python learners.