一尘不染

使用Pycharm调试PyQt gui时出现奇怪的错误

python

我一直在使用PyCharm在PyQt中调试我的GUI。到目前为止,这确实非常成功,直到我在尝试调试gui时遇到一个奇怪的错误。我已经在脚本的开始以及各个点设置了一个断点,但是程序没有机会到达这一点。我也尝试删除所有断点并运行调试,但得到相同的结果。完整的回溯是:

C:\Users\pbreach\Continuum\Anaconda3\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 53720 --file C:/Users/pbreach/Dropbox/FIDS/cci/bluebook/code/input.py
Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 2, in <module>
    from _pydevd_bundle.pydevd_cython import trace_dispatch, PyDBAdditionalThreadInfo
ModuleNotFoundError: No module named '_pydevd_bundle.pydevd_cython'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevconsole.py", line 8, in <module>
    from code import InteractiveConsole
ImportError: cannot import name 'InteractiveConsole'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevd.py", line 26, in <module>
    from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_additional_thread_info.py", line 17, in <module>
    from _pydevd_bundle.pydevd_cython_wrapper import PyDBAdditionalThreadInfo
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 26, in <module>
    mod = __import__(check_name)
  File "_pydevd_bundle\pydevd_cython_win32_36_64.pyx", line 9, in init _pydevd_bundle.pydevd_cython_win32_36_64 (_pydevd_bundle/pydevd_cython_win32_36_64.c:21388)
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_frame.py", line 10, in <module>
    from _pydevd_bundle.pydevd_breakpoints import get_exception_breakpoint
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_breakpoints.py", line 15, in <module>
    from _pydevd_bundle.pydevd_comm import get_global_debugger
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 75, in <module>
    import pydevconsole
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevconsole.py", line 10, in <module>
    from _pydevd_bundle.pydevconsole_code_for_ironpython import InteractiveConsole
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevconsole_code_for_ironpython.py", line 105
    except SyntaxError, err:
                      ^
SyntaxError: invalid syntax

Process finished with exit code 1

有谁知道导致此错误的原因以及如何解决?当我正常运行代码(无需调试)时,不会遇到任何这些错误。


阅读 310

收藏
2021-01-20

共1个答案

一尘不染

我遇到了同样的问题,花了我一段时间,但我找到了适合我的解决方案。我相信发生的事情是调试器正在_pydevd_bundle.pydevd_cython目录中查找模块code。但是,由于您是在自己的code目录之外运行脚本,因此调试器将检查您的文件夹,发现它们不是模块,并引发错误。那将解释为什么删除__init__.py作品,因为调试器将不再混淆这两个目录。

因此,将您的代码目录重命名为其他目录,应该可以解决此问题,并保留初始化文件。

2021-01-20