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

大城市里の小女人 提交于 2019-11-29 10:50:19

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!