Errors using sys from Python Embedded in C++
<p>I am using Eclipse to run C++. In my code,I use a High Level Embedding of Python to run a function. When I try to use sys and import it. I get the error:</p>

<p><em>Fatal Python error: no mem for sys.argv</em></p>

<p>CODE:</p>

<pre><code>#include &lt;python3.4m/Python.h&gt;
#include &lt;iostream&gt;
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

int main(int argc, char **argv)
{

    Py_Initialize();
    PySys_SetArgv(argc, (wchar_t**)argv);
    PyRun_SimpleString("import sys\n");
    Py_Finalize();
    return 0;
}
</code></pre>

<p>When I run the .exe from Terminal I get </p>

<p><em>ValueError: character U+384d2f2e is not in range [U+0000; U+10ffff]
Aborted</em></p>

<p>Any help is appreciated in resolving this problem.
Thank you.</p>

<p>The error was that Python expected an **argv to point to a set of unicode values. Instead argv was pointing to chars.</p>

<p>To solve this:</p>

<pre><code>wchar_t **wargv;
wargv = (wchar_t**)malloc(1*sizeof(wchar_t *));
*wargv = (wchar_t*)malloc(6*sizeof(wchar_t));
**wargv = L'argv1';

Py_Initialize();
PySys_SetArgv(1, (wchar_t**)wargv);
PyRun_SimpleString("import sys\n"
                   "print('test')\n");
Py_Finalize();
return 0;
</code></pre>

<p>Hope this helps someone else.</p>

python c++ unicode sys python-embedding