非常简单的最小示例:
if __name__ == '__main__':
print("Still ok")
raise Exception("Dummy exception")
print("End of Program")
我在使用Python 3.6的PyCharm 2019.2调试器中运行该输出时得到此输出:
/usr/bin/python3.6 /home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 46850 --file /home/[...]/test_traceback.py
pydev debugger: process 18394 is connecting
Connected to pydev debugger (build 192.5728.105)
Still ok
此时,调试器中断了执行流程,但在调试器控制台中未显示“回溯和异常”消息。如果我在PyCharm 2018.1中运行相同的,它会在遇到断点时正确显示这些。
当我点击时,我得到了期望的输出,但是由于该过程结束,所以我再也无法在调试上下文中运行代码了。
Traceback (most recent call last):
File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 2060, in <module>
main()
File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 2054, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 1405, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "/home/[...]/pycharm-community-2019.2/helpers/pydev/pydevd.py", line 1412, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/[...]/pycharm-community-2019.2/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/[...]/test_traceback.py", line 4, in <module>
raise Exception("Dummy exception")
Exception: Dummy exception
Process finished with exit code 1
我的断点配置:
答案 0 :(得分:4)
它适用于 PyCharm(社区)2019. 1.4 :
似乎您遇到了(回归)错误:
会影响 v2019.2.1 ,并已计划在 v2019.2.3 中修复。
>要解决此问题,您必须:
安装(在 20190930 上)最新修补程序( v2019.2.3 ),并且存在追溯 PyCharm 的控制台(因此,该错误已修复)。
答案 1 :(得分:0)
您是否在每个可执行行的开头都检查了空格?纠正空白后,我想到的这种情况已经解决了。