Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyexiv2 with homebrew python 2.7.4

I have just installed python (2.7.4) with brew on my macbook pro (10.7.5). I also installed exiv2 and pyexiv2 with brew. When I import pyexiv2 from the python interpreter, I got the following error :

Fatal Python error: Interpreter not initialized (version mismatch?)

What I should do to correct that (considering that I do not want to remove the brewed python as suggested in this thread: How to install python library Pyexiv2 and Gexiv2 on osx 10.6.8?)

Thanks a lot for any advice !

like image 784
jean Avatar asked May 18 '13 11:05

jean


2 Answers

After much searching and looking at a few complicated solutions across the web, I found a simple method to solve this problem, in the Homebrew wiki itself!

The root of the problem is the boost dependency library, which by default links to the system python and not a brewed python, from the 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.

(emphasis mine)

  1. So first uninstall the dependency libraries and pyexiv2 itself with:

    brew rm $(brew deps pyexiv2)
    brew rm pyexiv2
    
  2. Then install boost from source as indicated here:

    brew install boost --build-from-source
    

    Note: building boost might take time, so be patient, it took my system 27.9 mins! (output below)

    usr/local/Cellar/boost/1.54.0: 9865 files, 568M, built in 27.9 minutes
    
  3. Then reinstall pyexiv2 and dependencies:

    brew install pyexiv2
    

That's it, now importing pyexiv2 should work flawlessly.

like image 163
bool.dev Avatar answered Oct 13 '22 03:10

bool.dev


Check which Python you are running (which python), and run python with the -v option to see where it is looking for modules. Check that all those things match your expectations. Then run brew doctor, and if that doesn't complain about anything, report a bug.

like image 42
Peter Eisentraut Avatar answered Oct 13 '22 01:10

Peter Eisentraut