I'm starting to play with the library pybind11. It's really good library, well documented and it works for me but only with Python 2.7. I'm not able to get it working for Python 3.5 and I don't know what I'm doing wrong.
This is my "hello world" program:
#include <pybind11/pybind11.h>
namespace py = pybind11;
const char * world() { return "Hello world!"; }
int main(int argc, char ** argv) {
Py_Initialize();
py::module m("hello", "my hello world Python module with pybind11");
m.def("world", &world);
PyRun_SimpleString("import hello\nprint( hello.world() )");
Py_Finalize();
return 0;
}
If I compile and link against 2.7, I get the expected result:
Hello world!
But if I link exactly the same code with Python 3.5, I get an error loading the module.
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'hello'
Any ideas?