Python 在 macOS High Sierra 上找不到调试器 pdb
Python debugger pdb not found on macOS High Sierra
PythonDebuggingTools documentation says that the Python debugger pdb
是"part of all Python installations",但我在macOS High Sierra下找不到:
pdb: command not found
这些天它应该作为 macOS 的正常部分安装吗?
没有名为 pdb
的命令,但您可以从 shell 使用以下命令调用 pdb:
python -m pdb your_script.py
您可以在 its doc.
中阅读更多调用 pdb
的方法
如果您使用 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。
PythonDebuggingTools documentation says that the Python debugger pdb
是"part of all Python installations",但我在macOS High Sierra下找不到:
pdb: command not found
这些天它应该作为 macOS 的正常部分安装吗?
没有名为 pdb
的命令,但您可以从 shell 使用以下命令调用 pdb:
python -m pdb your_script.py
您可以在 its doc.
中阅读更多调用pdb
的方法
如果您使用 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。