我在Python 2.7中尝试在MacOSX上使用pygtk3并抛出此错误:
>>> from gi.repository import Gtk
** (process:1970): WARNING **: Failed to load shared library 'libgtk-3.0.dylib' referenced by the typelib: dlopen(libgtk-3.0.dyldylib, 9): image not found
** (process:1970): WARNING **: Failed to load shared library 'libgdk-3.0.dylib' referenced by the typelib: dlopen(libgdk-3.0.dyldylib, 9): image not found
** (process:1970): WARNING **: Failed to load shared library 'libatk-1.0.0.dylib' referenced by the typelib: dlopen(libatk-1.0.0.dyldylib, 9): image not found
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/gtk3/lib/python2.7/site-packages/gi/importer.py", line 76, in load_module
dynamic_module._load()
File "/opt/gtk3/lib/python2.7/site-packages/gi/module.py", line 224, in _load
overrides_modules = __import__('gi.overrides', fromlist=[self._namespace])
File "/opt/gtk3/lib/python2.7/site-packages/gi/overrides/Gtk.py", line 50, in <module>
class Widget(Gtk.Widget):
File "/opt/gtk3/lib/python2.7/site-packages/gi/module.py", line 154, in __getattr__
interfaces = tuple(interface for interface in get_interfaces_for_object(info)
File "/opt/gtk3/lib/python2.7/site-packages/gi/module.py", line 83, in get_interfaces_for_object
interfaces.append(getattr(module, name))
File "/opt/gtk3/lib/python2.7/site-packages/gi/module.py", line 243, in __getattr__
return getattr(self._introspection_module, name)
File "/opt/gtk3/lib/python2.7/site-packages/gi/module.py", line 180, in __getattr__
wrapper = metaclass(name, bases, dict_)
File "/opt/gtk3/lib/python2.7/site-packages/gi/types.py", line 232, in __init__
register_interface_info(cls.__info__.get_g_type())
TypeError: must be an interface
感谢所有人。 拉斐尔·科尔达诺