[Answered ]-Ipdb is triggering ImportError

1👍

I was using virtualenv-burrito. Deleting my venv, updating burrito (virtualenv-burrito upgrade) and making a new virtual environment fixed the problem.

1👍

I just set up a whole virtual env just to try this out because it must be a simple fix. I managed to set up ipdb in my virtual env and I will write what I did step by step.

$ virtualenv foo
$ cd foo
$ source ./bin/activate  # activate venv

… at this point which python and which pip gives me the right python executable inside my virtual env. Then next:

(venv: foo)$ pip install ipython

At this point, which ipython gives me the right ipython executable inside my virtual env. It’s important to make sure that it points to the right executables, if it doesn’t show the right executable, but the global one, re-activate your virtual env. It is crucial that ipython (and all your executables) point to the right executables inside your virtualenv.

Then I’m gonna try importing ipdb:

(venv: foo)$ ipython
In [1]: import ipdb
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-2d6f026194dd> in <module>()
----> 1 import ipdb

ImportError: No module named 'ipdb'

Module not found, because it hasn’t been installed yet. Let’s do it:

(venv: foo)$ pip install ipdb

and try it again:

(venv: foo)$ ipython                                                                                                          [ 16-05-24 22:28 ]
Python 3.5.1 (default, Jan 29 2016, 19:58:36) 
Type "copyright", "credits" or "license" for more information.

IPython 4.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import ipdb

In [2]: 

It seems to work for me. I was using zsh and python3 but it shouldn’t matter. Your issue is most likely that it’s not being installed in the right places, meaning is using global executables instead of the ones from the virtualenv.

From within my virtualenv you could see that ipdb is installed:

(venv: foo)$ find . -name ipdb
./lib/python3.5/site-packages/ipdb

I hope all this write up helps 🙂

Leave a comment