Why doesn't #include <Python.h> work?

I normally circumvent this by using the non-debug Python lib in debug builds. Typically, this leads to code like:

#ifdef _DEBUG
  #undef _DEBUG
  #include <Python.h>
  #define _DEBUG
#else
  #include <Python.h>
#endif

where you hide the definition of _DEBUG during the inclusion of Python.h.


I don't know much about python, but the message indicates that python27_d.lib either doesn't exist, or at least doesn't exist where the linker is looking for it.

You already fixed the compiler include issue, now find the python27_d.lib file with Windows Explorer and and add that path to the Additional Library Dependencies path. It's under Configuration -> Linker -> General -> Additional Library Directories.

The "_d" indicates it's a debug library, so you'll want that one for your Debug configuration, and the one without the "_d" (probably) for your release configuration.


Put visual studio in release mode instead of debug.