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

升级PyCharm 2023.3.3后无法调试异步测试,报AttributeError错误

PyCharm 2023.3.3调试异步测试报错:AttributeError: 'ProactorEventLoop' object has no attribute '_compute_internal_coro'

问题重现

升级PyCharm至2023.3.3版本(Build #PY-233.13763.11,构建于2024年1月25日)后,调试异步测试时调试器运行失败,抛出错误:

pycharm AttributeError: 'ProactorEventLoop' object has no attribute '_compute_internal_coro'

当前使用pytest-asyncio==0.23.4,问题与该库版本无关。

可行解决方案

  • 切换事件循环(Windows系统适用):在测试代码入口处添加以下代码,强制使用SelectorEventLoop替代默认的ProactorEventLoop:

    import asyncio
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
    
  • 降级PyCharm版本:临时回退到2023.2.x系列等稳定版本,等待JetBrains官方修复该调试器兼容性bug。

  • 临时禁用PyCharm调试器特定特性:在pytest的运行/调试配置中,添加环境变量PYCHARM_DEBUG=False,此方法会关闭部分调试功能,但可绕过当前报错。

  • 检查Python版本兼容性:若使用Python 3.12及以上版本,尝试降级到Python 3.11.x,部分用户反馈该组合可解决问题。

内容的提问来源于stack exchange,提问作者koks der drache

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 16:53:12