You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Thonny编辑器中help函数调用异常问题求助

问题:Thonny控制台执行help(print)触发AttributeError报错

环境信息

  • OS:macOS Monterey 12.4(Ubuntu用户也遇到相同问题)
  • 编辑器:Thonny
  • 安装方式:通过pip3命令安装,使用已有的Python 3.9解释器

操作与报错情况

  1. 在Thonny控制台执行代码:help(print)
  2. 执行后无输出,程序处于等待输入状态,按下回车后出现如下报错:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1892, in __call__
    return self.func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 814, in callit
    func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/thonny/running.py", line 548, in _poll_backend_messages
    if self._pull_backend_messages() is False:
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/thonny/running.py", line 561, in _pull_backend_messages
    msg = self._proxy.fetch_next_message()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/thonny/plugins/cpython_frontend/cp_front.py", line 138, in fetch_next_message
    msg = super().fetch_next_message()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/thonny/running.py", line 1218, in fetch_next_message
    if msg.event_type == "ProgramOutput":
AttributeError: 'InputSubmission' object has no attribute 'event_type'

解决思路

  • 升级Thonny到最新版本:该报错属于Thonny后端与Python解释器通信的兼容性bug,新版本通常会修复这类问题。执行命令pip3 install --upgrade thonny完成升级,之后重启Thonny测试。
  • 改用官方安装包安装:pip安装的Thonny可能和系统Python环境存在依赖冲突,使用Thonny官方提供的对应系统独立安装包进行安装,避免依赖系统自带的Python 3.9。
  • 重置Thonny配置:打开Thonny,依次点击Tools -> Options -> General,选择Reset settings to defaults,重置后重启编辑器,再执行help(print)测试。
  • 切换Python解释器版本:在Thonny的Tools -> Options -> Interpreter中,切换到其他Python版本(如3.10及以上),验证是否是Python 3.9与当前Thonny版本的特定兼容性问题。

内容的提问来源于stack exchange,提问作者Sebastien Hoarau

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 21:55:27