【问题标题】:Python debugger pdb not found on macOS High Sierra在 macOS High Sierra 上找不到 Python 调试器 pdb
【发布时间】:2018-05-23 13:13:52
【问题描述】:

PythonDebuggingTools 文档说 Python 调试器 pdb 是“所有 Python 安装的一部分”,但我在 macOS High Sierra 下找不到它:

pdb: command not found

现在它应该作为 macOS 的正常部分安装吗?

【问题讨论】:

    标签: python debugging macos-high-sierra


    【解决方案1】:

    没有名为 pdb 的命令,但您可以从 shell 调用 pdb:

    python -m pdb your_script.py
    

    您可以阅读更多在its doc 中调用pdb 的方法。

    【讨论】:

      【解决方案2】:

      如果您使用 IPython,则可以使用

      调用调试器
      IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
      
      In [1]: %pdb
      Automatic pdb calling has been turned ON
      
      In [2]: %pdb
      Automatic pdb calling has been turned OFF
      
      In [3]: ?pdb
      Docstring:
      Control the automatic calling of the pdb interactive debugger.
      
      Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
      argument it works as a toggle.
      
      When an exception is triggered, IPython can optionally call the
      interactive pdb debugger after the traceback printout. %pdb toggles
      this feature on and off.
      
      The initial state of this feature is set in your configuration
      file (the option is ``InteractiveShell.pdb``).
      
      If you want to just activate the debugger AFTER an exception has fired,
      without having to type '%pdb on' and rerunning your code, you can use
      the %debug magic.
      File:      ~/anaconda/envs/py36/lib/python3.6/site-packages/IPython/core/magics/execution.py
      

      您可能需要使用 pip 或 conda 安装 IPython。

      【讨论】:

        猜你喜欢
        • 2018-10-19
        • 1970-01-01
        • 2018-01-27
        • 2021-01-07
        • 1970-01-01
        • 2018-12-05
        • 2018-03-06
        • 2019-03-05
        • 1970-01-01
        相关资源
        最近更新 更多