安装dlib python模块获取segfault

时间:2015-11-20 19:16:26

标签: python boost installation cmake dlib

我试图安装dlib python模块,但每次尝试导入它时都会遇到像这样的段错误和python崩溃。

└[~/Devspace/dlib]> python 
Python 2.7.10 (default, Sep 23 2015, 04:34:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
[1]    50326 segmentation fault  python

我没有收到任何其他错误消息,所以我不知道如何解决此问题。我在OS X上使用自制软件安装了boost和python(以及symlinked over system python)。我一直在搜索,我发现这通常是由boost和python的不兼容版本引起的,这可能是由于使用自制版本引起的系统python的库。我很确定这是原因,但CMake在编译时告诉我这个

-- Detecting CXX compile features - done
-- Boost version: 1.59.0
-- Found the following Boost libraries:
--   python
-- Found PythonLibs: /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (found suitable version "2.7.10", minimum required is "2.6")
-- USING BOOST_LIBS: /usr/local/lib/libboost_python-mt.dylib
-- USING PYTHON_LIBS: /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
-- Enabling SSE4 instructions
 *****************************************************************************

所以我知道python libs和boost libs都来自自制的托管/usr/local/bin,而不是系统管理的/usr/bin/。使完成很好并返回成功,甚至似乎安装一切都很好。

Install the project...
-- Install configuration: "Release"
-- Installing: /Users/gabriel/Devspace/dlib/tools/python/../../python_examples/dlib.so
Populating the distribution directory /Users/gabriel/Devspace/dlib/./dist/dlib ...
Copying file /Users/gabriel/Devspace/dlib/./python_examples/correlation_tracker.py -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/correlation_tracker.py.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/dlib.so -> /Users/gabriel/Devspace/dlib/./dist/dlib/dlib.so.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/face_detector.py -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/face_detector.py.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/face_landmark_detection.py -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/face_landmark_detection.py.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/find_candidate_object_locations.py -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/find_candidate_object_locations.py.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/LICENSE_FOR_EXAMPLE_PROGRAMS.txt -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/LICENSE_FOR_EXAMPLE_PROGRAMS.txt.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/max_cost_assignment.py -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/max_cost_assignment.py.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/sequence_segmenter.py -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/sequence_segmenter.py.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/svm_rank.py -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/svm_rank.py.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/svm_struct.py -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/svm_struct.py.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/train_object_detector.py -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/train_object_detector.py.
Copying file /Users/gabriel/Devspace/dlib/./python_examples/train_shape_predictor.py -> /Users/gabriel/Devspace/dlib/./dist/dlib/examples/train_shape_predictor.py.
running build_py
creating build
creating build/lib.macosx-10.11-x86_64-2.7
creating build/lib.macosx-10.11-x86_64-2.7/dlib
copying dist/dlib/__init__.py -> build/lib.macosx-10.11-x86_64-2.7/dlib
running egg_info
creating dist/dlib.egg-info
writing dist/dlib.egg-info/PKG-INFO
writing top-level names to dist/dlib.egg-info/top_level.txt
writing dependency_links to dist/dlib.egg-info/dependency_links.txt
writing manifest file 'dist/dlib.egg-info/SOURCES.txt'
reading manifest file 'dist/dlib.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '**' found under directory 'dlib/build'
warning: no files found matching '*.bat' under directory 'python_examples'
warning: no previously-included files matching '**' found under directory 'python_examples/build'
writing manifest file 'dist/dlib.egg-info/SOURCES.txt'
copying dist/dlib/dlib.so -> build/lib.macosx-10.11-x86_64-2.7/dlib
creating build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/LICENSE_FOR_EXAMPLE_PROGRAMS.txt -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/__init__.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/correlation_tracker.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/face_detector.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/face_landmark_detection.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/find_candidate_object_locations.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/max_cost_assignment.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/sequence_segmenter.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/svm_rank.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/svm_struct.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/train_object_detector.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
copying dist/dlib/examples/train_shape_predictor.py -> build/lib.macosx-10.11-x86_64-2.7/dlib/examples
running build_ext

之后它安装在我的python站点包中,可以用pip看到

└[~/Devspace/dlib]> pip freeze      
appnope==0.1.0
colorama==0.3.3
cv2==1.0
cycler==0.9.0
decorator==4.0.4
dlib==18.18.99
gnureadline==6.3.3
imutils==0.3

但如果我尝试导入它,它总会导致段错误。我正在使用包含的setup.py进行安装,并且认为如果python / boost没有匹配,我可能需要自己运行CMake,但它们看起来很好。有人对我有什么建议吗?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

请参阅我的回答here。我提交了一个PR,它在OS X上使用自己的Python来处理它。