c++ - import error in embedding python with boost python -
i have following code
#include <boost/python.hpp> int main() { py_initialize(); namespace python = boost::python; try { python::object main = python::import("sample"); } catch(...) { pyerr_print(); pyerr_clear(); } }
i following error:
importerror: no module named sample
i put sample.py @ same directory program.
it's because python::import not looking inside current directory. know 2 ways solve it:
set pythonpath inside current directory (linux):
export pythonpath=`pwd`:$pythonpath
or...
set python search module path inside code (also provides better explanation issue you've found out): how import work boost.python inside python files
Comments
Post a Comment