解决 Connection to Python debugger failed Socket closed 及 (most likely due to a circular import) 问题处理

这篇具有很好参考价值的文章主要介绍了解决 Connection to Python debugger failed Socket closed 及 (most likely due to a circular import) 问题处理。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

问题背景以及问题描述:

在debug 过程中,出现了 Connection to Python debugger failed Socket closed 错误具体报错为:

Traceback (most recent call last):
  File "/home/Downloads/pycharm-community-2022.3.1/plugins/python-ce/helpers/pydev/pydevd.py", line 45, in <module>
    from _pydevd_bundle.pydevd_comm import CMD_SET_BREAK, CMD_SET_NEXT_STATEMENT, CMD_STEP_INTO, CMD_STEP_OVER, \
  File "/home/Downloads/pycharm-community-2022.3.1/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 91, in <module>
    from _pydevd_bundle import pydevd_console_integration
  File "/home/Downloads/pycharm-community-2022.3.1/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_console_integration.py", line 21, in <module>
    from _pydevd_asyncio_util.pydevd_nest_asyncio import apply
  File "/home/Downloads/pycharm-community-2022.3.1/plugins/python-ce/helpers/pydev/_pydevd_asyncio_util/pydevd_nest_asyncio.py", line 33, in <module>
    import asyncio
  File "/home/anaconda3/envs/pyslowfast/lib/python3.10/asyncio/__init__.py", line 8, in <module>
    from .base_events import *
  File "/home/anaconda3/envs/pyslowfast/lib/python3.10/asyncio/base_events.py", line 18, in <module>
    import concurrent.futures
  File "/home/anaconda3/envs/pyslowfast/lib/python3.10/concurrent/futures/__init__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "/home/anaconda3/envs/pyslowfast/lib/python3.10/concurrent/futures/_base.py", line 7, in <module>
    import logging
  File "/home/PYTHON-PROJ/Contrast_learing/SAIC_MAEST/util/logging.py", line 12, in <module>
    import torch
  File "/home/anaconda3/envs/pyslowfast/lib/python3.10/site-packages/torch/__init__.py", line 457, in <module>
    for name in dir(_C):
NameError: name '_C' is not defined

Process finished with exit code 1

因此下意识我想run它(省略写)依然有错误 ,那么先解决 run 的问题:


    LOGGER = logging.getLogger("concurrent.futures")
AttributeError: partially initialized module 'logging' has no attribute 'getLogger' (most likely due to a circular import)

Process finished with exit code 1

 

解决过程及问题成因:

看到问题的核心是(most likely due to a circular import) 即为一个 循环的引用

那么大概率就是logging 这个模块有 循环引用

果然文件同路径下有 logging.py 并且 在 logging.py 中 还 import 了 logging,造成了循环引用


解决方案:

更改 名字 避免循环引用:

connection to python debugger failed socket closed,python,开发语言

把原logging.py 更名为logging1.py

即可解决问题


结论及重点:

造成 Connection to Python debugger failed Socket closed 的原因会有很多,需要具体去看错误,循序渐进即可解决,在本例(most likely due to a circular import)中造成该情况的原因则是循环引用文章来源地址https://www.toymoban.com/news/detail-772921.html


到了这里,关于解决 Connection to Python debugger failed Socket closed 及 (most likely due to a circular import) 问题处理的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包