boost_python import error: module does not define init function

前端 未结 2 1126
一个人的身影
一个人的身影 2021-01-01 13:16

First off: I looked at the related questions, but they are not very helpful unfortunately. I\'m trying to wrap an enum and a class from an external library.

         


        
相关标签:
2条回答
  • 2021-01-01 13:29

    The name used in BOOST_PYTHON_MODULE must match the name of the .so library you generate and import into python.

    0 讨论(0)
  • 2021-01-01 13:44

    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.

    0 讨论(0)
提交回复
热议问题