[C++-sig] problem importing my own module
collar at gamic.com
Mon Oct 13 16:20:19 CEST 2003
Here's the other problem I've been fighting with today and haven't found an
answer for yet. Perhaps I've totally misunderstood what has to be done in my
code. I'd appreciate it if someone could help me accomplish the following.
1. Write a module that exposes a little bit of my library code
2. Using the embedded interpreter, evaluate a python script which imports the
code written in 1.
1. I've gotten a script to import the module I made and print some
results--just calling the script from the command line.
2. However, whenever I attempt "import MyModule" with code like what's below,
I get an core dump:
handle<> main_module(borrowed( PyImport_AddModule("__main__") ));
handle<> main_namespace(borrowed( PyModule_GetDict(main_module.get()) ));
handle<> x( PyRun_String(
, Py_file_input, main_namespace.get(), main_namespace.get()) );
Thanks for any help or explanation. I guess I'd really like know what kind of
linking or C code is necessary to allow importing my module in the script.
The module (built with bjam under the boost/libs/python directory) is
available within the PYTHONPATH. I also copied the .so to
/usr/lib/python2.2/site-packages but it still core dumps.
I don't mind having a PyImport_AddModule call in my code, but I haven't gotten
any of those sort of calls working yet either.
(o__ Benjamin Collar
//\ GAMIC mbH ++49 (0)241 889 110
V_/_ Developer/System Administrator
To know recursion, you must first know recursion
More information about the Cplusplus-sig