[C++-sig] How to get output from python embedded in VC++

Jian thecolors at 126.com
Mon Jul 31 22:33:44 EDT 2017


Hi Stefan,


Sorry for the late update. Changing to 'python35.dll' does not work. I guess there were something wrong when I complied the boost::python. I have been working on this for few days but I failed to find any error.


So now I'm trying to use the console created along with main MFC frame. It captures everything although it still looks not very good . I have found the way to optimize its behaviors as an embedded window control. then I could continue to focus on the main works.

Thanks a lot for your kind help.

Best Regards,


John.


At 2017-07-23 23:06:38, "Stefan Seefeld" <stefan at seefeld.name> wrote: >On 23.07.2017 03:15, Jian wrote: >> >> Hi Stefan, >> >> I still got a assertion failed at Py_Initialize(). Below is the message. >> >> Program: C:\Python35\python35_d.dll >> File: ..\Objects\object.c >> Line: 84 >> Expression: (op->_ob_prev == NULL) == (op->_ob_next == NULL) > >And you get this output from the Py_Initialize() call itself ?? I have >no idea how this could happen. I have very little experience with >Windows, and so am not really able to help debug this. My first guess >would be that you are linking to the wrong library. (I see >'python35_d.dll'. What happens if you link to 'python35.dll', i.e. the >non-debug version ?) > >> >> I also pasted mo code below. This function is invoked by a button >> click function. No other codes around it. >> >> int runBoostPython() >> { >> Py_Initialize(); >> try { >> //boost::python::object main_module = >> // boost::python::import("__main__"); >> //boost::python::object main_namespace = >> // main_module.attr("__dict__"); >> boost::python::dict main_namespace; >> >> boost::python::object ignored = exec_file("test1.py", >> main_namespace, main_namespace); >> >> std::wstring output = >> boost::python::extract<std::wstring>(main_namespace["return_value"]); > >I'm not sure it's possible to use `extract` with std::wstring. At least >I have never used it with that. (What encoding is your string using ? >How should it be converted to a wide string ?) > > >> >> } >> catch (boost::python::error_already_set) { >> PyErr_Print(); >> } >> return 0; >> } >> >> Please help check it. >> >> Thanks & Best Regards, >> >> John. > >Regards, > Stefan > >-- > > ...ich hab' noch einen Koffer in Berlin... > >_______________________________________________ >Cplusplus-sig mailing list >Cplusplus-sig at python.org >https://mail.python.org/mailman/listinfo/cplusplus-sig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20170801/e6de903e/attachment.html>


More information about the Cplusplus-sig mailing list