AttributeError: module ‘thread‘ has no attribute ‘start_new_thread‘

问题描述

使用 PyCharm 进行 debug 调试程序时出现如下问题 AttributeError: module 'thread' has no attribute 'start_new_thread'

D:\Anaconda\envs\transformer\python.exe "D:/PyCharm 2022.3/plugins/python/helpers/pydev/pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 34768 --file "E:\Code\PyCharm\YOLOv7Fatigue Detection\main.py" 
已连接到 pydev 调试器(内部版本号 223.7571.203)Traceback (most recent call last):
  File "D:/PyCharm 2022.3/plugins/python/helpers/pydev/pydevd.py", line 2195, in <module>
    main()
  File "D:/PyCharm 2022.3/plugins/python/helpers/pydev/pydevd.py", line 2177, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "D:/PyCharm 2022.3/plugins/python/helpers/pydev/pydevd.py", line 1451, in run
    self.prepare_to_run()
  File "D:/PyCharm 2022.3/plugins/python/helpers/pydev/pydevd.py", line 1339, in prepare_to_run
    self.patch_threads()
  File "D:/PyCharm 2022.3/plugins/python/helpers/pydev/pydevd.py", line 1355, in patch_threads
    patch_thread_modules()
  File "D:\PyCharm 2022.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 876, in patch_thread_modules
    patch_thread_module(t)
  File "D:\PyCharm 2022.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 839, in patch_thread_module
    _original_start_new_thread = thread_module._original_start_new_thread = thread_module.start_new_thread
AttributeError: module 'thread' has no attribute 'start_new_thread'

在这里插入图片描述

原因分析:

出现这个问题的原因可能是你的项目路径下有一个 thread 的目录或者 py 文件,导致文件冲突了

解决方案:

将你项目目录下的 thread 重命名

猜你喜欢

转载自blog.csdn.net/m0_47256162/article/details/130263050
今日推荐