Python pdb debugger not found on macOS High Sierra

The PythonDebuggingTools documentation says that the Python debugger pdbis “part of all Python installations”, but I cannot find it under macOS High Sierra:

pdb: command not found

Should it be installed as a regular part of macOS these days?

+4
source share
2 answers

There is no command named pdb, but you can call pdb from the shell with:

python -m pdb your_script.py

You can read more methods to call pdbinto his document .

+10
source

if you are using IPython, the debugger can be called using

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

You may need to install IPython using pip or conda.

0

Source: https://habr.com/ru/post/1690479/


All Articles