1

我正在尝试安装 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(并通过系统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库和boost库都来自自制程序管理/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,但它们对我来说看起来不错。有人对我有什么建议吗?任何帮助将不胜感激。

4

1 回答 1

2

在这里查看我的答案。我提交了一个PR,它使用 brewed Python 在 OS X 上为我处理它。

于 2016-02-11T21:07:52.947 回答