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

2017-07-31 Thread Jian
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

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

2017-07-23 Thread Stefan Seefeld
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 th

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

2017-07-23 Thread Jian
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) I also pasted mo code below. This function is invoked by a button click fu

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

2017-07-22 Thread Stefan Seefeld
On 21.07.2017 23:17, Jian wrote: > Hi Imre, > > I tried to use boost.python as you advised. Build boost.python with > > But I got a error in the import.hpp as below: > import.hpp start > > namespace boost > { > namespace python >

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

2017-07-22 Thread Jian
Hi Stefan, Thanks for your suggestion. First of all, I answer your question. I only want to capture the output&input from python when I call py file or import a module in C/C++ code. It works something like a debug output window does. I could only guess that Python uses something like print

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

2017-07-22 Thread Jian
Hi Imre, I tried to use boost.python as you advised. Build boost.python with But I got a error in the import.hpp as below: import.hpp start namespace boost { namespace python { object BOOST_PYTHON_DECL import(str name) {

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

2017-07-22 Thread Jian
Dear Imre, Thanks a lot. I'm not using boost::python but the original way from the official website. Main code to invoke py module are below 2 lines. pName = PyUnicode_DecodeFSDefault("test1"); pModule = PyImport_Import(pName); and below is my py file: import emb print("Number of arguments

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

2017-07-21 Thread Horváth Imre István
Hi John! If you want to embed python in c++ app and exchange data between c++ and python, take a look at the boost::python library. It's also a platform independent solution (my app's target platforms are windows vs2015 and linux CentOS7). You can do something like this: using namespace boos

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

2017-07-21 Thread Stefan Seefeld
On 21.07.2017 10:03, Jian wrote: > > Then, I have tried this method. It works. I got the text print from > the file. below are the code I used following your advice. > > import sys > original = sys.stdout > sys.stdout = open('redirect.txt', 'w') > ... > other code! > ... > sys.stdout.close() > sys.

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

2017-07-21 Thread Horváth Imre István
Hi John! If you want to embed python in c++ app and exchange data between c++ and python, take a look at the boost::python library. It's also a platform independent solution (my app's target platforms are windows vs2015 and linux CentOS7). You can do something like this: using namespace boos

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

2017-07-20 Thread Stefan Seefeld
On 19.07.2017 23:25, Jian wrote: > > Dear Gurus, > > I want to embed python interpreter in my program. What I want is to > redirect those output to a control such as RICHEDIT which can be > modified as a output window in my program. So I can write *.py files > outside of program and invoke it insid