boost_python import error: module does not define init function
The name used in BOOST_PYTHON_MODULE
must match the name of the .so
library you generate and import into python.
I have seen this exception before. I got it using Visual Studio on windows, so things might be a little different over in unix-oid land but:
Two Possibilities:
Debug/Release miss-match:
You are trying to import a debug build of your module into a release build of python (or vice-versa). The solution is to include boost/python/detail/wrap_python.hpp
instead of Python.h
. This will fix some includes and defines to make it possible to do what you want.
Python/Boost.Python version miss-match: Boost.Python is compiled against one specific version of python. You are using it with a different version. For example: you seem to be using python 2.7. Your boost_python library might be compiled against python 2.6. Yes, this means that your module can only work with one version of python at a time.