X-Received: by 10.129.55.16 with SMTP id e16mr16717325ywa.44.1458411122975; Sat, 19 Mar 2016 11:12:02 -0700 (PDT) X-Received: by 10.50.87.40 with SMTP id u8mr124480igz.0.1458411122929; Sat, 19 Mar 2016 11:12:02 -0700 (PDT) Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!w104no7522861qge.1!news-out.google.com!u9ni1932igk.0!nntp.google.com!nt3no3032816igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Sat, 19 Mar 2016 11:12:02 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=105.227.168.170; posting-account=LqJMdgoAAACqAM-qb3RhApFAp0PG2jAH NNTP-Posting-Host: 105.227.168.170 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5126641d-d2e2-42e9-81d7-b599e805dee2@googlegroups.com> Subject: Bug in embeddable code or in my code? From: Sgoodman Injection-Date: Sat, 19 Mar 2016 18:12:02 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 2056 X-Received-Body-CRC: 2037147302 Xref: csiph.com comp.lang.python:105285 Hi, When I run the code below, I manage to execute certain python code but not some simple imports. For example, the code below... (I removed some error checking/reference checks for brevity) // ... Py_SetProgramName(L"AAAAA"); Py_SetPath(L"path\\to\\python35.zip"); // embeddable from the python site. Py_Initialize(); PyThreadState *mainstate = PyThreadState_Get(); PyInterpreterState* mainInterpreterState = mainstate->interp; PyObject *main_module = PyImport_AddModule("__main__"); PyObject *main_dict = PyModule_GetDict(main_module); PyObject *local_dic = PyDict_New(); const char* s = "import ctypes\n"; PyObject * PyRes = PyRun_String(s, Py_file_input, main_dict, local_dic); PyObject* ex = PyErr_Occurred(); if (NULL != ex) { // didn't work, import error. } // cleanup... // ... I can do some imports, ("import sys" for example), but most of the others do not work, "import ctypes" for example. Any suggestions as to what I might be missing? S.