ImportError: No module named gtk

Bug #22587 reported by David Sedeño Fernandez
10
Affects Status Importance Assigned to Milestone
pygtk (Ubuntu)
Invalid
Medium
Ubuntu Desktop Bugs

Bug Description

I have installed all the python-gtk2 related packages in a hoary to breezy
updated system. When I try to run python-gtk2 apps like update-manager:

# update-manager
Traceback (most recent call last):
  File "/usr/bin/update-manager", line 27, in ?
    import gtk
ImportError: No module named gtk

david@ubuntu:~ $ dpkg -l | grep python | grep gtk
ii python-gtk2 2.8.0-0ubuntu3
Python bindings for the GTK+ widget set
ii python-gtk2-dev 2.8.0-0ubuntu3
GTK+ bindings: devel files
ii python2.4-gtk2 2.8.0-0ubuntu3
Python bindings for the GTK+ widget set

I have no idea why my python installation didn't see the gtk module...

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for your bug. What does "env | grep PY" write? And "python -c "import
sys; print sys.path"?

Revision history for this message
David Sedeño Fernandez (david-alderia) wrote :

"env | grep PY" doesn't print anything.

$ python -c "import sys; print sys.path"
['', '/usr/lib/python24.zip', '/usr/lib/python2.4',
'/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk',
'/usr/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/HTMLgen',
'/usr/lib/python2.4/site-packages/Numeric',
'/usr/lib/python2.4/site-packages/PIL',
'/usr/lib/python2.4/site-packages/cairo',
'/usr/lib/python2.4/site-packages/gtk-2.0']

Thanks

Revision history for this message
Sebastien Bacher (seb128) wrote :

what about "ls /usr/lib/python2.4/site-packages/gtk-2.0", "ls
/usr/lib/python2.4/site-packages/gtk-2.0/gtk"?

Revision history for this message
David Sedeño Fernandez (david-alderia) wrote :

# ls /usr/lib/python2.4/site-packages/gtk-2.0
atk.la dsextras.pyo gda.so gnomecanvas.la gobject.la
gtkmozembed.la gtkspell.so nautilusburn.so totem
atk.so egg gksu gnomecanvas.so gobject.so
gtkmozembed.so gtop.la pangocairo.la wnck.la
bonobo gconf.la gnome gnomeprint gtk
gtksourceview.la gtop.so pangocairo.so wnck.so
dsextras.py gconf.so gnomeapplet.la gnomevfs.la gtkhtml2.la
gtksourceview.so LaunchpadIntegration pango.la
dsextras.pyc gda.la gnomeapplet.so gnomevfs.so gtkhtml2.so
gtkspell.la nautilusburn.la pango.so

# ls /usr/lib/python2.4/site-packages/gtk-2.0/gtk
compat.py compat.pyc compat.pyo glade.la glade.so _gtk.la _gtk.so
__init__.py __init__.pyc __init__.pyo keysyms.py keysyms.pyc keysyms.pyo

Revision history for this message
Sebastien Bacher (seb128) wrote :

could you run "strace -e open python -c "import gtk"" and copy that to a comment?

Revision history for this message
David Sedeño Fernandez (david-alderia) wrote :

Created an attachment (id=4257)
strace -e open python -c "import gtk"

Revision history for this message
David Sedeño Fernandez (david-alderia) wrote :

From the strace I see that the search path maybe wrong:

In my system I have:
# ls -l /usr/lib/python2.4/site-packages/gtk-2.0/pangocairo.so
-rw-r--r-- 1 root root 10896 2005-09-25 23:12
/usr/lib/python2.4/site-packages/gtk-2.0/pangocairo.so

Instead, in the strace it's looks for:
/usr/lib/python2.4/site-packages/gtk-2.0/gtk/pangocairo.so

Revision history for this message
Sebastien Bacher (seb128) wrote :

it seems that the "import gtk" works as expect.

what does "python -c "import gtk; print gtk.gtk_version"? update-manager runs
with sudo, maybe you have something set for it? Does pygtk-demo run as expected?

Revision history for this message
David Sedeño Fernandez (david-alderia) wrote :

$ python -c "import gtk; print gtk.gtk_version"
(2, 8, 4)

$ pygtk-demo
Traceback (most recent call last):
  File "/usr/bin/pygtk-demo", line 7, in ?
    execfile(os.path.join(pygtklibdir, "pygtk-demo.py"))
  File "/usr/lib/pygtk/2.0/pygtk-demo.py", line 18, in ?
    import gobject
ImportError: No module named gobject

I don't have anything special for update-manager.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Do you still have that issue?

Revision history for this message
David Sedeño Fernandez (david-alderia) wrote :

Well, I did a clean breezy install and all works ok. Maybe a hoary -> breezy upgrade issue only.

Revision history for this message
Joseph Seaton (greenpenguin-mailing) wrote :

Is this a duplicate of bug #30514?

This problem appears to be on dapper too.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Rejecting that bug, that seems to be a local issue fixed for the submitter (if that was an upgrade issue we would have received other bugs about that). #30514 is probably an another issue. Feel free to reopen if you get the issue again.

Changed in pygtk:
assignee: seb128 → desktop-bugs
status: Needs Info → Rejected
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.