<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Python integrieren]]></title><description><![CDATA[<p>Hallo ich wollte letztens mal versuchen Python in ein C++ Projekt einzubinden.<br />
Ich wollte dazu noch kein boost verwenden.</p>
<p>Ich bekomme aber stets folgende Fehlermeldung zu:</p>
<p>#include&lt;Python.h&gt;</p>
<p>no such file or directory</p>
<p>Muss ich diese datei noch zusätzlich installieren (und wenn ja in welchem debian-paket ist sie?)<br />
oder ist es prinzipiell nicht möglich python ohne boost zu integrieren?</p>
<p>ich wollte folgendes im netz gefundenes beispiel testen:</p>
<pre><code>#include &lt;Python.h&gt;

int main(int argc, char *argv[])
{
    PyObject *pName, *pModule, *pDict, *pFunc, *pValue;

    if (argc &lt; 3) 
    {
        printf(&quot;Usage: exe_name python_source function_name\n&quot;);
        return 1;
    }

    // Initialize the Python Interpreter

    Py_Initialize();

    // Build the name object

    pName = PyString_FromString(argv[1]);

    // Load the module object

    pModule = PyImport_Import(pName);

    // pDict is a borrowed reference 

    pDict = PyModule_GetDict(pModule);

    // pFunc is also a borrowed reference 

    pFunc = PyDict_GetItemString(pDict, argv[2]);

    if (PyCallable_Check(pFunc)) 
    {
        PyObject_CallObject(pFunc, NULL);
    } else 
    {
        PyErr_Print();
    }

    // Clean up

    Py_DECREF(pModule);
    Py_DECREF(pName);

    // Finish the Python Interpreter

    Py_Finalize();

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/261067/python-integrieren</link><generator>RSS for Node</generator><lastBuildDate>Sun, 24 May 2026 22:25:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/261067.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 12 Feb 2010 22:46:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Python integrieren on Fri, 12 Feb 2010 22:46:10 GMT]]></title><description><![CDATA[<p>Hallo ich wollte letztens mal versuchen Python in ein C++ Projekt einzubinden.<br />
Ich wollte dazu noch kein boost verwenden.</p>
<p>Ich bekomme aber stets folgende Fehlermeldung zu:</p>
<p>#include&lt;Python.h&gt;</p>
<p>no such file or directory</p>
<p>Muss ich diese datei noch zusätzlich installieren (und wenn ja in welchem debian-paket ist sie?)<br />
oder ist es prinzipiell nicht möglich python ohne boost zu integrieren?</p>
<p>ich wollte folgendes im netz gefundenes beispiel testen:</p>
<pre><code>#include &lt;Python.h&gt;

int main(int argc, char *argv[])
{
    PyObject *pName, *pModule, *pDict, *pFunc, *pValue;

    if (argc &lt; 3) 
    {
        printf(&quot;Usage: exe_name python_source function_name\n&quot;);
        return 1;
    }

    // Initialize the Python Interpreter

    Py_Initialize();

    // Build the name object

    pName = PyString_FromString(argv[1]);

    // Load the module object

    pModule = PyImport_Import(pName);

    // pDict is a borrowed reference 

    pDict = PyModule_GetDict(pModule);

    // pFunc is also a borrowed reference 

    pFunc = PyDict_GetItemString(pDict, argv[2]);

    if (PyCallable_Check(pFunc)) 
    {
        PyObject_CallObject(pFunc, NULL);
    } else 
    {
        PyErr_Print();
    }

    // Clean up

    Py_DECREF(pModule);
    Py_DECREF(pName);

    // Finish the Python Interpreter

    Py_Finalize();

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1854919</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1854919</guid><dc:creator><![CDATA[shisha]]></dc:creator><pubDate>Fri, 12 Feb 2010 22:46:10 GMT</pubDate></item><item><title><![CDATA[Reply to Python integrieren on Sat, 13 Feb 2010 04:41:50 GMT]]></title><description><![CDATA[<p>Lies doch das Tutorial aus dem du den Code kopiert hast mal ganz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1854943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1854943</guid><dc:creator><![CDATA[ohmann]]></dc:creator><pubDate>Sat, 13 Feb 2010 04:41:50 GMT</pubDate></item><item><title><![CDATA[Reply to Python integrieren on Sat, 13 Feb 2010 08:34:41 GMT]]></title><description><![CDATA[<p>Wie soll der Compiler Python.h finden, wenn du sie ihm nicht angegeben hast?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1854953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1854953</guid><dc:creator><![CDATA[Hobby Programmierer]]></dc:creator><pubDate>Sat, 13 Feb 2010 08:34:41 GMT</pubDate></item><item><title><![CDATA[Reply to Python integrieren on Sat, 13 Feb 2010 16:11:10 GMT]]></title><description><![CDATA[<p>naja ich dachte da des in &lt;&gt; klammern war dass er das schon findet, aber anscheinend hab ich eh 2 Python.h</p>
<p>nun hab ich des manuell mit eingebunden und hab das nächste problem:</p>
<pre><code class="language-cpp">#include &lt;QtCore/QCoreApplication&gt;
#include &quot;/usr/include/python3.1/Python.h&quot;

int main()
{
    Py_Initialize();

    return 0;
}
</code></pre>
<p>führt zu:</p>
<pre><code>/home/anubis/py/main.cpp:5: undefined reference to `Py_Initialize'
ld returned 1 exit status
</code></pre>
<p>was mach ich denn da falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855080</guid><dc:creator><![CDATA[shisha]]></dc:creator><pubDate>Sat, 13 Feb 2010 16:11:10 GMT</pubDate></item><item><title><![CDATA[Reply to Python integrieren on Sat, 13 Feb 2010 17:12:17 GMT]]></title><description><![CDATA[<p>was muss ich denn noch einbinden libpython oder so?<br />
weiß leider nicht genau was ich mitlinken muss</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855124</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855124</guid><dc:creator><![CDATA[shisha]]></dc:creator><pubDate>Sat, 13 Feb 2010 17:12:17 GMT</pubDate></item><item><title><![CDATA[Reply to Python integrieren on Sat, 13 Feb 2010 17:24:22 GMT]]></title><description><![CDATA[<p>shisha schrieb:</p>
<blockquote>
<p>was muss ich denn noch einbinden libpython oder so?</p>
</blockquote>
<p>Oder so... In deinem Fall wäre das libpython3.1.</p>
<p>Am besten benutzt du pkg-config um sowas herauszubekommen, und zwar auch in deinen Makefiles o.ä.:</p>
<pre><code>pkg-config python3 --cflags
pkg-config python3 --libs
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1855127</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855127</guid><dc:creator><![CDATA[dooooomi]]></dc:creator><pubDate>Sat, 13 Feb 2010 17:24:22 GMT</pubDate></item></channel></rss>