whats wrong with my python setup?

Can any python guru out there explain whats going on here:


$ /usr/bin/gnome-about
Traceback (most recent call last):
File "/usr/bin/gnome-about", line 35, in ?
import gtk
ImportError: No module named gtk

$ head -n 1 /usr/bin/gnome-about
#!/usr/bin/python

$ head -n 36 /usr/bin/gnome-about|tail -n +29

import pygtk
pygtk.require ('2.0')

import gobject
from gobject.option import OptionParser, make_option
import gtk

$ /usr/bin/python
Python 2.4.5 (#2, Mar 12 2008, 00:15:51)
[GCC 4.2.3 (Debian 4.2.3-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygtk
>>> import gtk
>>>

$ /usr/bin/python
Python 2.4.5 (#2, Mar 12 2008, 00:15:51)
[GCC 4.2.3 (Debian 4.2.3-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygtk
>>> pygtk.require ('2.0')
>>> import gtk
Traceback (most recent call last):
File "", line 1, in ?
ImportError: No module named gtk
>>>

UPDATE: Thanks to Karl-Lattimer, the problem was solved by:

# rm /usr/bin/python
# ln -s /usr/bin/python2.5 /usr/bin/python

Comments

Anonymous said…
Verify that there is no "gtk" in your PYTHONPATH, and verify that there is no directory named "gtk" in your "."!

Have a nice day,

Laurent
Shahms said…
Try launching it with 'python -v -v'. It'll print debugging output for loading modules, including what it's trying to find where. It may help you track down why one fails while the other succeeds.
Anonymous said…
seems like you're using a debian sid because of your python2.4 version 2.4.5.
in a recent sid installation the default python version is already 2.5.2, so I'm pretty sure an 'apt-get update && apt-get dist-upgrade' will help you.
otherwise try to reinstall python-gtk2 and try to locate the _gtk.so files via 'dpkg -L python-gtk2|grep gtk\.so'

so long

:wq buz
Anonymous said…
What is the contents of your sys.path before and after running pygtk.require(2.0) ? In both cases there should be '/var/lib/python-support/python2.5/gtk-2.0' which is the place where the gtk module is to be found.

Popular posts from this blog

Welcome to the virtual world!

clutter-gst

zbus and Implementing Async Rust API