Boost.Python __init__() should return None, not 'NoneType'

后端 未结 1 699
旧巷少年郎
旧巷少年郎 2020-12-10 15:56

I have a whole bunch of working C++ code that I want to write Python bindings for. I\'m trying to use Boost.Python since it seems to be the easiest way to get this working,

相关标签:
1条回答
  • 2020-12-10 16:36

    This error is probably due to linking against the wrong Python library. Make sure your extension as well as the Boost Python library are linked against the Python installation you are using to import the module.

    On Linux you can check against which libraries you've linked with ldd. On OS X otool -L does the same thing. So, for example

    otool -L libpcap_ext.so
    otool -L /path/to/libboost_python-mt.dylib
    

    should list the Python library they are linked against.

    With CMake you can use the variable PYTHON_LIBRARY to change which Python library is used. As an example, on the command line you can set it with

    cmake -DPYTHON_LIBRARY="/path/to/libpython2.7.dylib" source_dir
    

    Lastly, on OS X a quick and dirty way (i.e. without recompiling) to change the dynamically linked libraries is install_name_tool -change.

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