Using site-packages with alt-installed Python version

Tuomas Vesterinen tuomas.vesterinen at iki.fi
Sun May 16 14:29:10 EDT 2010


On 05/16/2010 02:38 PM, Alister wrote:
> On Sun, 16 May 2010 12:07:08 +0300, Tuomas Vesterinen wrote:
>
>> I am testing an application GUI with Python 2.4, 2.5 and 2.6. The native
>> Python (in Fedora 12) is 2.6. Versions 2.4 and 2.5 are alt-installed.
>>
>> Aplication GUI uses:
>> import pygtk
>> pygtk.require('2.0')
>> import gtk
>> import gobject
>>
>> I go to:
>> $ cd /usr/local/lib/python2.4/site-packages
>>
>> and say:
>> $ sudo ln -s /usr/lib/python2.6/site-packages/pygtk.py pygtk.py $ sudo
>> ln -s /usr/lib/python2.6/site-packages/gtk-2.0 gtk-2.0
>>
>> and try:
>> $ python2.4 gui_utils.py
>> Traceback (most recent call last):
>>     File "gui_utils.py", line 57, in ?
>>       import gtk
>>     File
>> "/usr/local/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line
>> 30, in ?
>>       import gobject as _gobject
>>     File
>> "/usr/local/lib/python2.4/site-packages/gtk-2.0/gobject/__init__.py",
>> line 26, in ?
>>       from glib import spawn_async, idle_add, timeout_add,
>> timeout_add_seconds, \
>>     File
>> "/usr/local/lib/python2.4/site-packages/gtk-2.0/glib/__init__.py", line
>> 22, in ?
>>       from glib._glib import *
>> ImportError: /usr/lib/libpyglib-2.0-python.so.0: undefined symbol:
>> _PyObject_CallFunction_SizeT
>>
>> What I should say more to get access to the GTK?
>>
>> Tuomas Vesterinen
>
> I am not a great expert on this But I think you need to use the Redhat
> alternatives system to switch between versions rather than trying to
> change things manually.
>
> as i understand it the Alternatives system sets up and changes various
> symlinks to ensure everything works correctly.
>

Yes, my first trial is not the solution because byte compiled .pyc files 
must be produced by the corresponding Python version.

PEP 3147 http://www.python.org/dev/peps/pep-3147 suggests a common 
solution, but only for Python 3.2 and perhaps 2.7. So I am still looking 
for hints. Have You some helpful links to those "Alternatives system"?

Tuomas Vesterinen



More information about the Python-list mailing list