2013-05-18 75 views
5

我剛剛在我的macbook pro(10.7.5)上安裝了python(2.7.4)和brew。 我還用brew安裝了exiv2和pyexiv2。 當我輸入pyexiv2從Python解釋器,我得到了以下錯誤:pyexiv2 with homebrew python 2.7.4

致命的Python錯誤:解釋器未初始化(?版本不匹配)

我應該怎麼做糾正(考慮到我不想除去釀造蟒蛇的建議在此線程: How to install python library Pyexiv2 and Gexiv2 on osx 10.6.8?

非常感謝任何意見!

回答

4

經過大量搜索,並在網絡上查找一些複雜的解決方案後,我找到了一個簡單的方法來解決這個問題,在Homebrew wiki itself

的問題的根源是boost依賴性庫,它由缺省鏈接到系統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 
    

    注:建設提升可能需要一段時間,所以要有耐心,花了我的系統27.9分鐘! (下面輸出)

    usr/local/Cellar/boost/1.54.0: 9865 files, 568M, built in 27.9 minutes 
    
  3. 然後重新安裝pyexiv2和依賴:

    brew install pyexiv2 
    

就是這樣,現在進口pyexiv2應該工作得很好。

+1

謝謝!它完美地工作。 – jean

+1

在29.5分鐘釀造。奇蹟般有效。非常非常感謝你! –

+0

@ user1781670很高興幫助! –

1

檢查您正在運行的Python(which python),並使用-v選項運行python以查看它在哪裏查找模塊。檢查所有這些事情是否符合您的期望。然後運行brew doctor,如果沒有抱怨什麼,請報告錯誤。

0

我在使用上面的bool.dev的答案在macOS Sierra上安裝了自制軟件pyexiv2時遇到了一些麻煩。 Homebrewed pyexiv2在導入時不斷拋出Segmentation Fault 11。

我最終得到了它安裝並通過修改bool.dev的用下面的命令答案與Python的家釀工作:

brew install boost --build-from-source 
brew install boost-python 
brew install exiv2 
sudo pip install git+https://github.com/escaped/pyexiv2.git 

我發現在following document第30頁最後一行得到吸下來後谷歌孔。

希望這有助於!