python exception <type 'exceptions.ImportError'> No module named gdb:

quant picture quant · Sep 1, 2014 · Viewed 20.8k times · Source

I've just compiled gdb 7.8 from source in my home directory on a server machine running linux. I had previously been using gdb 7.6, and aside from stability issues with gdb itself (the reason for the upgrade) everything worked fine.

Since the upgrade of gdb, when I run cgdb 0.6.7 I immediately get the following message:

Python Exception <type 'exceptions.ImportError'> No module named gdb:

warning:
Could not load the Python gdb module from `/home/username/bin/gdb//python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.

When I built gdb, I used ./configure --with-python.

When I run cgdb and my program reaches a segfault, I type backtrace and get the following message:

Python Exception No module named gdb.frames:

So it seems like I am effectively unable to use gdb/cgdb without python support. What can I do to resolve this?

FWIW; I don't use python, I usually write c++.

Answer

Nan Xiao picture Nan Xiao · Sep 1, 2014

You should specify the value of "--data-directory". For example, if you load gdb from the build directory, the command should be:

./gdb -data-directory ./data-directory

Then gdb can know where to find python module.

You can refer this discussion.