1

我对 gtk 有一个小问题。我将它导入到我之前编写的一些 python 代码中,现在每当我导入它时,它都会在解释器上加载该代码。有没有办法消除这种依赖?

>>> import gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/gtk-2.0/gtk/__init__.py", line 30, in <module>
    import gobject as _gobject
  File "/usr/lib/pymodules/python2.6/gtk-2.0/gobject/__init__.py", 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/option.py", line 33, in <module>
    import optparse
  File "/usr/lib/python2.6/optparse.py", line 90, in <module>
    from gettext import gettext
  File "/usr/lib/python2.6/gettext.py", line 49, in <module>
    import locale, copy, os, re, struct, sys
  File "copy.py", line 42, in <module>
    clipboard = gtk.clipboard_get()
AttributeError: 'module' object has no attribute 'clipboard_get'

谢谢

4

1 回答 1

2

您已将其中一个脚本称为“copy.py”,从而copy在 stdlib 中隐藏模块。重命名它。

于 2012-04-04T02:37:30.623 回答