[Pythonmac-SIG] Easy way to avoid Fatal Python error: Interpreter not initialized (version mismatch?)

Ivan Vilata i Balaguer ivilata at carabos.com
Wed Jul 25 18:46:29 CEST 2007


I've been looking for some hours for a more-or-less easy solution or
workaround to the

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

error that didn't imply uninstalling additional Pythons and the like, so
I'm posting this here so at least people can find it when googling for
it. ;)  Quite surely not the best solution, but it looks quite simple.

The problem comes from an extension being linked against the *default*
Python (i.e. the one which pops up when running ``python``) instead of
the requested one.  When using GCC with ``-framework Python``, it
accesses the Python framework in ``/Library/Frameworks/Python.framework``,
and it uses some components right under it which happen to be links to
paths under ``Versions/Current``, which is linked to the default
version.  In fact, when you inspect the extension which fails to load
with ``otool -L EXTENSION.so`` you can see it's linked with the wrong
Python library.

The workaround for this is kludgy as I warned but at least is quite
simple.  It consists in *changing the default Python version* before
building the failing extension::

    $ cd /Library/Frameworks/Python.framework/Versions
    $ sudo rm Current && sudo ln -s 2.4 Current
    $ cd your_project_path
    $ python2.4 setup.py build_or_whatever

Of course, change "2.4" to whatever Python version you need -- as long
as it is installed. ;)  If you want to recover your default version,
simply run the first two lines with the proper version number.

Just my 2 euro cents,

::

	Ivan Vilata i Balaguer   >qo<   http://www.carabos.com/
	       Cárabos Coop. V.  V  V   Enjoy Data
	                          ""
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: Digital signature
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20070725/18cadb9f/attachment.pgp 


More information about the Pythonmac-SIG mailing list