Debugging a Python Extension in Eclipse

Each Answer to this Q is separated by one/two green lines.

I have a Python extension that I have successfully built and used on Windows, OSX, and linux. I now need to be able to debug this Python extension. I am averse to the use of gdb at the command line, so I would really like to get this to work in Eclipse.

To begin with, I did my best to follow the instructions in, and I added the folder for the Python source as well as the folder for the python extension code as source folders to the empty project. Since it is relatively easy to get debug builds of everything required on linux, I started out with the debug development in Ubuntu.

Once I got a debug build of python (lets call it python_d), I ran the for my extension with

python_d build

which should also yield a debug build of the extension module. I have verified that symbols are being exported by opening the extension as an application in Eclipse and I can see the source code linked with the Python shared object.

Now if I create another project in Eclipse with the folder of my code, and add a breakpoint in the source that is used to create the extension, it doesn’t stop at the breakpoint. It is entirely possible that I am missing something rather critical here, but for the life of me I can’t get it to work. The crux of the problem is:

How can you get Eclipse to stop at a breakpoint in a Python extension module?

Which compiler are you using, MSVC or GCC? For MSVC, you can start python first, and attach the python_d.exe (windbg or visual studio), then you can load your module, setup the breakpoint, you can verify whether your module’s symbol got loaded in the debug->module windows (MSVC).

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .