Starting python debugger automatically on error

前端 未结 13 2284
南方客
南方客 2020-11-27 08:44

This is a question I have wondered about for quite some time, yet I have never found a suitable solution. If I run a script and I come across, let\'s say an IndexError, pyth

13条回答
  •  长情又很酷
    2020-11-27 09:33

    If you are running a module:

    python -m mymodule
    

    And now you want to enter pdb when an exception occurs, do this:

    PYTHONPATH="." python -m pdb -c c mymodule/__main__.py
    

    (or extend your PYTHONPATH). The PYTHONPATH is needed so that the module is found in the path, since you are running the pdb module now.

提交回复
热议问题