I am debugging some python code in emacs using pdb and getting some import issues. The dependencies are installed in one of my bespoked virtualenv environments.
Pdb
Possibly, your pdb command is tied to a certain specific version.
$ ls -ald /usr/bin/pdb
lrwxrwxrwx 1 root root 6 Jun 2 23:02 /usr/bin/pdb -> pdb2.6
Then, look at the first line of pdb2.6. It contains
#! /usr/bin/python2.6
This is why pdb is stubborn and always seems to run under a specific version of Python. Because it really is! Actually, this sort of dependency makes sense for a piece of software like a symbolic debugger.
I've compiled python2.7 from sources and pdb is not there, apparently. After some scrutiny, I found pdb.py for python-2.7, under the lib folder. I've then created some symlinks to it, for convenience:
$ cd /opt/python-dev ##-- this is where I installed from sources
$ cd bin
$ sudo ln -s ../lib/python2.7/pdb.py pdb2.7
$ sudo ln -s pdb2.7 pdb
Now observe the first line of pdb2.7. It reads:
#! /usr/bin/env python
... which looks better than the previous version. It basically means that pdb will be launched under the current Python you have defined in your environment, whatever it is, instead of anything hardcoded, like /usr/bin/python or /usr/bin/python2.6 are. Good to know!
I've also removed pdb and pdb2.6 from system files, once I prefer to develop/debug inside virtualenv. Doing that, I will not be caught again by the same trick.
I hope it helps.