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

Pycharm 2022.2.3调试器因DeprecationWarning无法运行求助

PyCharm 2022.2.3 社区版 + Python 3.10 调试器无法运行的解决办法

问题描述

我了解此问题曾在相关Python 3.10警告的讨论中被提及,但使用最新的PyCharm 2022.2.3社区版搭配Ubuntu 22.04系统、Python 3.10环境时,仍无法运行调试器,报错信息如下:

Traceback (most recent call last):
...
    output_checker_thread = self.output_checker_thread = CheckOutputThread(self)
  File "/snap/pycharm-community/302/plugins/python-ce/helpers/pydev/pydevd.py", line 166, in __init__
    self.setName('pydevd.CheckAliveThread')
  File "/usr/lib/python3.10/threading.py", line 1246, in setName
    warnings.warn('setName() is deprecated, set the name attribute instead',
DeprecationWarning: setName() is deprecated, set the name attribute instead

解决办法

1. 手动修改PyDev调试器源码(修复根源)

报错源于PyDev调试器仍在使用Python 3.10已废弃的setName()方法,直接修改对应代码即可:

  • 打开路径 /snap/pycharm-community/302/plugins/python-ce/helpers/pydev/pydevd.py
  • 定位到第166行:self.setName('pydevd.CheckAliveThread')
  • 将其替换为:self.name = 'pydevd.CheckAliveThread'
  • 保存文件后重启PyCharm,再尝试启动调试器

2. 临时禁用DeprecationWarning(快速绕过)

若不想修改源码,可通过配置运行参数屏蔽警告:

  • 打开Run/Debug Configurations(右上角运行按钮下拉菜单→Edit Configurations)
  • 在对应配置的Environment variables中,点击编辑按钮
  • 添加环境变量:
    • 变量名:PYTHONWARNINGS
    • 变量值:ignore::DeprecationWarning
  • 保存配置后启动调试器

3. 升级PyCharm到更高版本(彻底解决)

PyCharm 2022.3及以上版本已修复Python 3.10的适配问题,直接升级IDE即可自动解决该调试器报错。

内容的提问来源于stack exchange,提问作者Leo Skhrnkv

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 14:20:37