Question

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 !

Was it helpful?

Solution

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.

OTHER TIPS

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.

I had a bunch of trouble installing pyexiv2 with Homebrew on macOS Sierra using bool.dev's answer above. The Homebrewed pyexiv2 kept throwing a Segmentation Fault 11 on import.

I eventually got it installed and working with the Homebrewed Python by modifying bool.dev's answer with the following commands:

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

I found the last line in the following document on Page 30 after getting sucked down a Google hole.

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top