Unable to import gtk after installing PyGObject

做~自己de王妃 提交于 2020-01-05 12:55:23

问题


I can import gtk without any problem previously. I made a GUI in glade for GTK+ 3. Then I thought that I would like to try GTK+ 3. So I installed PyGObject. I later found out that PyGObject has little documentation and I'm using Windows (makes things worse I know).

The problem is here, I can't use import gtk anymore. Neither can I use from gi.repository import Gtk. I've tried installing PyGTK bundle again but it doesn't help.

    >>> import gtk

    Traceback (most recent call last):
      File "<pyshell#0>", line 1, in <module>
        import gtk
      File "C:\Python27\lib\site-packages\gtk-2.0\gtk\__init__.py", line 30, in <module>
        import gobject as _gobject
      File "C:\Python27\lib\site-packages\gtk-2.0\gobject\__init__.py", line 26, in <module>
        from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
      File "C:\Python27\lib\site-packages\gtk-2.0\glib\__init__.py", line 22, in <module>
        from glib._glib import *
    ImportError: DLL load failed: The specified procedure could not be found.`

回答1:


This looks like C-level library is missing, or at least in a place where the Python wrappers can't find it. Try re-installing whichever version of the C library corresponds to which Python library you would like to use (GTK2 and GTK3 should, theoretically, be parallel installable, but that installing the newer PyGobject broke import gtk suggests that at least these particular bindings aren't for some reason).



来源:https://stackoverflow.com/questions/13794658/unable-to-import-gtk-after-installing-pygobject

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!