Fatal python error (OSX)ΒΆ

Tags: python

Fatal Python error: Interpreter not initialized (version mismatch?), sigh. It has been some time since I saw that one. One of those rare cases where you get an OSX error dialog with “The application Python quit unexpectedly”.

http://photos.reinout.vanrees.org/photos/546756549_VFEMA-M.jpg

From earlier bitter experiences of hiding-below-desks, drinking a gallon of wiskey and taking a soldering iron to my laptop, I’ve discovered that the cause is always some C-level library mismatch. Python code by itself doesn’t break this way (yeah!).

As soon as you depend on some external dependency (lxml’s libxml2/libxslt, expat, subversion bindings, sqlite, mysql), you’re in for trouble like this.

  • Mismatches between libraries. You compile to library A and B, but library A doesn’t find B, but uses B1.
  • Mismatches between python versions. Your compile/make/make install compiled against one python version, but you use another.
  • On OSX, especially mismatches between system libraries and, for instance, macports libraries can be a huge pain.

Best way to have some shot at finding the real problem: click on “report” in that OSX dialog and then click on the “problem details” tab and browse to the bottom. Look at all those library paths in there. Chances are that some are “/opt/local/Library” (macports) and some are “/System” (core OSX), for instance. Mixing those is probably your problem. Stick to the one or stick to the other.

Resolving it is quite another matter. For building python subversion bindings I had to do:

  • sudo port install python_select
  • sudo python_select python25 to select macports’ python as the default python on my system in place of OSX’s one. This only gets rid of some of the problems.
  • sudo port install subversion-python25bindings to install all subversion binding depencencies via macports so that no system libraries remained.

With lxml I had similar problems, in the end removing libcrypt from the compile solved the issue: that was the last remaining system library in an otherwise static build. That’s the kind of problem you can get with OSX and one point at which linux is better.

blog comments powered by Disqus
 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):