Erin Wolpert
Erin Wolpert

Reputation: 383

ImportError: No module named 'ipdb'

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!

Upvotes: 27

Views: 31484

Answers (4)

esg
esg

Reputation: 141

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!

Upvotes: 3

azzamsa
azzamsa

Reputation: 2135

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.

Upvotes: 0

Scott H
Scott H

Reputation: 2712

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.

Upvotes: 11

wim
wim

Reputation: 363566

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

pip install ipdb

Upvotes: 35

Related Questions