ImportError: No module named 'ipdb'
Asked Answered
P

4

27

I'm new to python and I'm trying to use the interactive python debugger in the standard python package. Whenever I run "import ipdb" in my text editor (atom) or in the command line through iPython then I get the error: ImportError: No module named 'ipdb'

Where is my ipdb module? It's still missing after I reinstalled python.

Thanks!

Pennon answered 15/1, 2016 at 3:51 Comment(0)
T
32

pdb is built-in. ipdb you will have to install.

pip install ipdb
Typehigh answered 15/1, 2016 at 3:54 Comment(1)
Worked for me! Thanks Wim!!Pennon
A
12

ipdb comes with ipython, so if you already have ipython installed you can access it through that package using the following:

from IPython.core.debugger import Pdb
ipdb = Pdb()

Then you can use ipdb just as though you had done import ipdb, such as:

ipdb.runcall(self, func, *args, **kwds)
ipdb.run(self, cmd, globals=None, locals=None)
# etc.

If you don't have ipython installed, then you can just use pdb which is the built-in debugger. The main difference is ipdb has some extra bells and whistles.

Abe answered 2/11, 2017 at 18:18 Comment(0)
D
3

In the specific case that you want a more featureful ipdb debugger (including things like autocomplete), ipython also has one built-in (from what I can tell it's actually the one that ipython uses by default). Specifically, you can instead run

from IPython.terminal.debugger import TerminalPdb
ipdb = TerminalPdb()

and get the same features as the commands from @Scott H's answer, but now you get autocomplete in the debugger that comes up!

Dayak answered 23/7, 2021 at 20:38 Comment(0)
B
0

If you installed using --user argument. You can check the executable name in ~/.local/bin. It's probably named ipdb3

$ ipdb
-bash: ipdb: command not found

$ ipdb3
usage: python -m ipdb [-c command] ... pyfile [arg] ...

Debug the Python program given by pyfile.
Brother answered 30/6, 2020 at 3:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.