我刚刚在我的 macbook pro (10.7.5) 上安装了带有 brew 的 python (2.7.4)。 我还用 brew 安装了 exiv2 和 pyexiv2。 当我从 python 解释器导入 pyexiv2 时,出现以下错误:
Python fatal error :解释器未初始化(版本不匹配?)
我应该做些什么来纠正这个问题(考虑到我不想按照这个线程中的建议删除 brew 的 python: How to install python library Pyexiv2 and Gexiv2 on osx 10.6.8? )
非常感谢任何建议!
最佳答案
经过大量搜索并在网上查看了一些复杂的解决方案后,我在 Homebrew wiki itself 中找到了解决此问题的简单方法。 !
问题的根源是 boost依赖库,默认情况下链接到系统 python 而不是 brewed python,来自 wiki :
Note that e.g. the boost bottle is built against system python and should be brewed from source to make it work with a brewed Python. This can even happen when both python executables are the same version (e.g. 2.7.2). The explanation is that Python packages with C-extensions (those that have .so files) are compiled against a certain python binary/library that may have been built with a different arch (e.g. Apple's python is still not a pure 64bit). Other things can go wrong, too. Welcome to the dirty underworld of C.
(强调我的)
所以首先卸载依赖库和 pyexiv2 本身:
brew rm $(brew deps pyexiv2) brew rm pyexiv2
然后按照指示从源安装
boost
here :brew install boost --build-from-source
注意:构建 boost 可能需要时间,所以请耐心等待,我的系统用了 27.9 分钟! (下面的输出)
usr/local/Cellar/boost/1.54.0: 9865 files, 568M, built in 27.9 minutes
然后重新安装 pyexiv2 和依赖项:
brew install pyexiv2
就是这样,现在导入 pyexiv2 应该可以完美地工作了。
关于python - 带有 Homebrew 软件 python 2.7.4 的 pyexiv2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16623902/