Can't Include Python.h In Visual Studio
(I do find a lot of similar questions, but so far non of these fits me...) ===========Updated error message, images, Command Line=========== I am trying to #include
Solution 1:
In Visual Studio Community 2015 I changed the "Active solution configuration" in Build \ Configuration Manager from 'Debug' to 'Release. That solved this problem for me.
I got my following example code from: Tutorial Python embedded in C++
#include<python.h>#include<stdio.h>#include<conio.h>intmain(){
CPyInstance pyInstance;
PyRun_SimpleString("print('Hello World from Embedded Python!!!')");
printf("\nPress any key to exit...\n");
if (!_getch()) _getch();
return0;
}
classCPyInstance
{
public:
CPyInstance()
{
Py_Initialize();
}
~CPyInstance()
{
Py_Finalize();
}
};
classCPyObject
{
private:
PyObject* p;
public:
CPyObject() : p(NULL)
{ }
CPyObject(PyObject* _p) : p(_p)
{ }
~CPyObject()
{
Release();
}
PyObject* getObject(){
return p;
}
PyObject* setObject(PyObject* _p){
return (p = _p);
}
PyObject* AddRef(){
if (p)
{
Py_INCREF(p);
}
return p;
}
voidRelease(){
if (p)
{
Py_DECREF(p);
}
p = NULL;
}
PyObject* operator ->()
{
return p;
}
boolis(){
return p? true : false;
}
operator PyObject* ()
{
return p;
}
PyObject* operator = (PyObject* pp)
{
p = pp;
return p;
}
operatorbool(){
return p ? true : false;
}
};
Post a Comment for "Can't Include Python.h In Visual Studio"