Python GTK Issue

Go To


I am having a slight problem with gtk. I imported it into some python code I wrote awhile back and now whenever I import it, it loads that code on the interpreter. Is there any way to remove that dependency?

>>> import gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/gtk-2.0/gtk/", line 30, in <module>
    import gobject as _gobject
  File "/usr/lib/pymodules/python2.6/gtk-2.0/gobject/", line 26, in <module>
    from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
  File "/usr/lib/pymodules/python2.6/gtk-2.0/glib/", line 33, in <module>
    import optparse
  File "/usr/lib/python2.6/", line 90, in <module>
    from gettext import gettext
  File "/usr/lib/python2.6/", line 49, in <module>
    import locale, copy, os, re, struct, sys
  File "", line 42, in <module>
    clipboard = gtk.clipboard_get()
AttributeError: 'module' object has no attribute 'clipboard_get'


2012-04-04 02:22
by Steve Shell
Show your work - Ignacio Vazquez-Abrams 2012-04-04 02:24
I was just trying to write some code in the python interpreter, in linux so just import pygtk pygtk.require('2.0') import gtk and then it runs an old fil - Steve Shell 2012-04-04 02:25
That's nice. Show your work - Ignacio Vazquez-Abrams 2012-04-04 02:26
Sorry but Im not really sure what work you want me to sho - Steve Shell 2012-04-04 02:29
Show the code that leads you to believe that you are seeing the issue that you believe you are seeing - Ignacio Vazquez-Abrams 2012-04-04 02:31
@IgnacioVazquez-Abrams I'm afraid these won't be such work you require. You see, the problem is just caused by a import gtk. Maybe something wrong with the package configurations or so - starrify 2012-04-04 02:38
@Pengyu: No, that's not it - Ignacio Vazquez-Abrams 2012-04-04 02:39
@SteveShell Can I assume you can reproduce this issue by simply open a new terminal with Python, and type import gtk, and then this error message would show - starrify 2012-04-04 02:40
@IgnacioVazquez-Abrams Oh, then my apologize and let's wait until Steve gives some more information - starrify 2012-04-04 02:42


You've called one of your scripts "", shadowing the copy module in the stdlib. Rename it.

2012-04-04 02:37
by Ignacio Vazquez-Abrams
Tried it still getting an error However I can get gtk to work if I create a new user account but I don't want to do it that wa - Steve Shell 2012-04-04 02:40
Is it the same error - Ignacio Vazquez-Abrams 2012-04-04 02:40
Yes but I just figured it out. For some reason it created another instance of the file located in a different folder and that was affecting it. Thanks for your hel - Steve Shell 2012-04-04 02:43