【问题标题】:Python segmentation fault 11 on OpenNI module import -- issues with Homebrew boost and python?OpenNI 模块导入上的 Python 分段错误 11 - Homebrew boost 和 python 的问题?
【发布时间】:2014-01-10 19:38:03
【问题描述】:

我正在 OSX 10.9 上运行自制版本的 python:Maverick。

短版:

当我尝试将 OpenNI 模块导入 python 时遇到Python segmentation fault 11。我已尝试按照以下链接中的建议重命名我的 readline.so 文件,所以我假设这是一个不同的问题:

Python crashing when running two commands (Segmentation Fault: 11)

我想知道这是否可能是我的自制 boost 安装没有链接到正确版本的 python 的问题。虽然我似乎无法修复它,而且很可能是在找错树。

很长的版本:

我一直在尝试按照该站点的说明安装 PyOpenNI python 模块: http://www.justinfx.com/2012/06/21/getting-started-with-xbox-360-kinect-on-osx/

我没有按照链接中的说明手动安装 OpenNI、NITE 和 Sensor Kinect 驱动程序,而是使用了我在此处找到的 brew 版本: https://github.com/totakke/homebrew-openni

在我到达最后一步安装 PyOpenNI 之前,一切似乎都运行良好。创建 make 文件时遇到 CMake 错误;它没有找到 OpenNI 库和包含目录。我手动将这些放在 CMakeCache.txt 文件中,之后安装似乎工作正常。

一旦我尝试在 python shell 中导入 openni 模块,我得到:

Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

谷歌搜索了一下,有人认为这是一个 Boost 错误,安装到 Python 的 Mac 版本而不是 Homebrew 版本。 Homebrew + Python on mac os x 10.8: Fatal Python error: PyThreadState_Get: no current thread importing mapnik

运行 otool -L $(brew list boost | grep 'python.*.dylib') 的输出表明是这种情况:

兴趣线:

/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.5)

完整输出:

/usr/local/Cellar/boost/1.55.0/lib/libboost_python-mt.dylib:
/usr/local/lib/libboost_python-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.5)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/usr/local/Cellar/boost/1.55.0/lib/libboost_python.dylib:
/usr/local/lib/libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.5)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

我卸载了 boost 并用brew install boost --build-from-source重新安装了它

有趣的是,安装后,它给出了这个警告:

The Boost bottle's module will not import into a Homebrew-installed Python.
If you use the Boost Python module then please:
  brew install boost --build-from-source

这显然很有趣,因为我刚刚这样做了。再次运行otool

兴趣线:

/usr/local/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)

完整输出:

/usr/local/Cellar/boost/1.55.0/lib/libboost_python-mt.dylib:
/usr/local/lib/libboost_python-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/local/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/usr/local/Cellar/boost/1.55.0/lib/libboost_python.dylib:
/usr/local/lib/libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/local/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

所以现在它似乎指向了一个不同的 python 框架目录,但似乎它仍然不是 Homebrew python 框架目录。

我在这个评估中是否正确,boost 仍然没有链接到 python 的自制版本?这会导致分段错误 11,还是完全由其他原因造成?

【问题讨论】:

  • 也许它会对某人有所帮助——我在一些 Homebrew 问题的 cmets 中读到分段错误通常意味着错误的 Python 二进制文件。例如,某些东西是针对系统 python 构建的,但针对 brewed python 运行。

标签: macos python-2.7 boost homebrew openni


【解决方案1】:

我知道答案很晚,但它可能对某人有帮助,就像对我一样。显然,akakcolin 发布了解决方案,作为对 Github 上 PyOpenNI 相关问题之一的回答。

  1. 重建自制 Python:

    brew update 然后brew doctor

    brew rm python

    brew install python --force --install-lib --install-headers --install-data --verbose

  2. 符号链接:

    ln -s /usr/local/Cellar/python/2.7.x/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib /usr/local/lib/(注意你使用的python版本)

  3. cmake 和制作:

    cmake ../PyOpenNI 你可能需要指定-D OPENNI_INCLUDE_DIR

    make

这对我来说适用于 Python 2.7.10 和 boost (with boost-python) 1.58.0

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-27
    • 1970-01-01
    • 2014-09-02
    • 2013-09-17
    • 1970-01-01
    • 2015-09-26
    • 1970-01-01
    • 2020-12-04
    相关资源
    最近更新 更多