python - 带有 Homebrew 软件 python 2.7.4 的 pyexiv2

标签 python homebrew pyexiv2

我刚刚在我的 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.

(强调我的)

  1. 所以首先卸载依赖库和 pyexiv2 本身:

    brew rm $(brew deps pyexiv2)
    brew rm pyexiv2
    
  2. 然后按照指示从源安装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
    
  3. 然后重新安装 pyexiv2 和依赖项:

    brew install pyexiv2
    

就是这样,现在导入 pyexiv2 应该可以完美地工作了。

关于python - 带有 Homebrew 软件 python 2.7.4 的 pyexiv2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16623902/

相关文章:

python - 如何在 python 中使用 gexiv2?

python - PyQt5 从另一种形式调用一种形式

Python 3 开发和分发挑战

ruby - 无法使用 Homebrew 在 Mac 上安装 Ruby

python - 从 python "Error: This command requires a Cask token"使用 Homebrew

python - 如何使用 PIL 维护图像调整大小的 exif 数据

python - 添加列表中除特定数字和以下数字之外的数字

python - 在 BeautifulSoup 中提取多个 Span 标签内的内容

python-3.x - Homebrew 错误 您的用户无法写入以下目录 :