python - 安装 dlib python 模块出现段错误

标签 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 上使用 homebrew 安装了 boost 和 python(并通过系统 python 进行了符号链接(symbolic link))。我一直在四处搜索,发现这通常是由 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,但它们对我来说看起来很好。有人对我有什么建议吗?任何帮助将不胜感激。

最佳答案

查看我的回答 here 。我提交了PR它可以在 OS X 上使用编写的 Python 为我解决这个问题。

关于python - 安装 dlib python 模块出现段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33834397/

相关文章:

python - 将多个目录中的同名文件复制到一个目录中

python - 在 Pandas 中剥离时区信息

python - 比较分组数据帧的值

python - Web.py Apache mod_wsgi url 重写

c++ - 使用boost计算CRC-5

curl: (48) 一个未知的选项被传递给 libcurl

c++ - 为什么 boost::mutex 使用原子操作和事件而不是临界区

c++ - 提取/构建 boost 程序_选项

macos - 如何在我的 Mac 上安装 JavaFx 2.0?

.net - 用于安装或卸载 .NET Windows 服务的批处理脚本