[C++-sig] Somewhat beginners error in using boost::python::list from C++?

Michael Wand michael.wand at kit.edu
Mon Jan 17 20:15:45 CET 2011


Hello,

yes, that's it. Thankyou for the quick response.

(The story: The original error occurred in a unittest file, which previously 
hadn't used python at all. The main program was running flawlessly all the 
time.)

That's it, have a nice evening

- Michael

On Saturday 15 January 2011 15:35:40 Stefan Seefeld wrote:
> On 2011-01-15 09:01, Michael Wand wrote:
> > int main() {
> > 
> >      boost::python::list myList;
> >      myList.append("foo");
> >      myList.append("fork");
> >      cerr<<  "Printing length of list."<<  endl;
> >      cerr<<  "Length of myList: "<<  boost::python::len(myList)<<  endl;
> > 
> > // the above line causes a segfault!
> > 
> >      cerr<<  "TheList: "<<  boost::python::extract<string>(myList[0])()<<
> >       ","
> >      
> >                    <<  boost::python::extract<string>(myList[1])()<< 
> >                    endl;
> >      
> >      cerr<<  "Finished"<<  endl;
> > 
> > }
> 
> You haven't initialized the Python runtime with "Py_Initialize()".
> 
>      Stefan

-- 
Dipl. Math. Michael Wand
Cognitive Systems Lab, Institute for Anthropomatics
Karlsruhe Institute of Technology
http://csl.anthropomatik.kit.edu/~mwand


More information about the Cplusplus-sig mailing list