[python] "Interpreter not initialized"

Hi, When I execute the following code: BEGIN CODE -------------------------------------------------- #define BOOST_PYTHON_DEF( func ) boost::python::def( #func, func ) using namespace boost::python; static char const* PrintHelloWorld() { return "Hello World!"; } BOOST_PYTHON_MODULE(Script) { BOOST_PYTHON_DEF( PrintHelloWorld ); } void BeginPythonTest() { try { Py_Initialize(); initScript(); Py_Finalize(); } catch( error_already_set const& /*err*/ ) { PyErr_Print(); } catch( std::invalid_argument const& /*err*/ ) { PyErr_Print(); } } -------------------------------------------------- END CODE I receive the following error message: *Fatal Python error: Interpreter not initialized (version mismatch?)* This occurs when I step over the call to initScript() (in the code snippet above). I have no idea why this is happening. I'm currently linking against boost 1.34.1. I built all the libraries for boost myself using bjam. I built the multithreaded debug and release shared libraries. I'm using the SDK from Python 2.5.1. I also built the debug and release shared libraries for Python myself. My operating system is Microsoft Windows XP Professional. All help is appreciated. Thanks in advance!

on Wed Feb 20 2008, "Robert Dailey"
Hi,
When I execute the following code:
BEGIN CODE -------------------------------------------------- #define BOOST_PYTHON_DEF( func ) boost::python::def( #func, func )
using namespace boost::python;
static char const* PrintHelloWorld() { return "Hello World!"; }
BOOST_PYTHON_MODULE(Script) { BOOST_PYTHON_DEF( PrintHelloWorld ); }
void BeginPythonTest() { try { Py_Initialize();
initScript();
Py_Finalize(); }
catch( error_already_set const& /*err*/ ) { PyErr_Print(); }
catch( std::invalid_argument const& /*err*/ ) { PyErr_Print(); } } -------------------------------------------------- END CODE
I receive the following error message: Fatal Python error: Interpreter not initialized (version mismatch?)
a. Boost.Python is not compatible with Py_Finalize b. Even if it were, you can't make any calls to the Python API (like PyErr_Print) after Py_Finalize. You'll get better help from the C++-sig: http://boost.org/more/mailing_lists.htm#cplussig -- Dave Abrahams Boost Consulting http://boost-consulting.com
participants (2)
-
David Abrahams
-
Robert Dailey