不能在 windows 上 运行 python。我错过了什么?

Cannot run python on windows. What am I missing?

我是 python 的新手。如果我表现得愚蠢,请指正我。

所以我正在尝试 运行 以下代码:

    from gi.repository import Gtk
class LisaMainWindow:

  def on_LisaMainWindow_destroy(self, object, data=None):
    print ("quit with cancel")
    Gtk.main_quit()

  def __init__(self):
    self.gladefile = "lisaMainWindow.glade"
    self.builder = Gtk.Builder()
    print ("gtk builder done")
    self.builder.add_from_file(self.gladefile)
    print ("glade loaded")
    self.builder.connect_signals(self)
    self.window = self.builder.get_object("lisaMainWindow")
    self.window.show()

if __name__ == "__main__":
  main = Buglump()
  Gtk.main()

我收到以下错误

** (python.exe:6388): WARNING **: Failed to load shared library 'libgtk-3-0.dll'
 referenced by the typelib: 'libgtk-3-0.dll': The specified module could not be
found.

** (python.exe:6388): WARNING **: Failed to load shared library 'libgdk-3-0.dll'
 referenced by the typelib: 'libgdk-3-0.dll': The specified module could not be
found.
Traceback (most recent call last):
  File "lisaMainWindow.py", line 2, in <module>
    from gi.repository import Gtk
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "C:\Python34\lib\site-packages\gi\importer.py", line 67, in load_module
    dynamic_module._load()
  File "C:\Python34\lib\site-packages\gi\module.py", line 296, in _load
    self._overrides_module = importlib.import_module('gi.overrides.' + self._nam
espace)
  File "C:\Python34\lib\importlib\__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Python34\lib\site-packages\gi\overrides\Gtk.py", line 118, in <module
>
    class Widget(Gtk.Widget):
  File "C:\Python34\lib\site-packages\gi\module.py", line 183, in __getattr__
    interfaces = tuple(interface for interface in get_interfaces_for_object(info
)
  File "C:\Python34\lib\site-packages\gi\module.py", line 109, in get_interfaces
_for_object
    interfaces.append(getattr(module, name))
  File "C:\Python34\lib\site-packages\gi\module.py", line 320, in __getattr__
    return getattr(self._introspection_module, name)
  File "C:\Python34\lib\site-packages\gi\module.py", line 222, in __getattr__
    wrapper = metaclass(name, bases, dict_)
  File "C:\Python34\lib\site-packages\gi\types.py", line 234, in __init__
    register_interface_info(cls.__info__.get_g_type())
TypeError: must be an interface

我是运行宁Windows 8 on 64 bit。 以下是我开发基于 Gtk 的 GUI 的安装。

  1. python-3.4.3.amd64.msi 来自 https://www.python.org/downloads/windows/

  2. pygi-aio-3.14.0_rev10-setup.exe 来自 http://sourceforge.net/projects/pygobjectwin32/files/

我错过了什么或做错了什么? 请帮忙。 (提前致谢)

我刚刚遇到了同样的问题。

为了解决这个问题,我安装了 GTK3+ http://www.gtk.org/download/win32.php 包含第 3 方依赖项的 GTK+ 堆栈的一体化捆绑包 在 http://win32builder.gnome.org/gtk+-bundle_3.6.4-20130921_win32.zip 在 somedir 中解压缩文件后。

你可以通过 运行ning somedir\bin\gtk3-demo.exe 来测试 您必须在 windows PATH 中添加包含 dll 文件的 bin 目录 运行 在控制台 > 找到要检查 dll 的 libgdk-3-0.dll 然后 运行 你的 python 文件。

刚遇到同样的问题(虽然是不同的版本),以前的版本没有这个问题。

作品: pygi-aio-3.14.0_rev15-setup.exe

无效: pygi-aio-3.14.0_rev16-setup.exe

http://softlayer-dal.dl.sourceforge.net/project/pygobjectwin32/pygi-aio-3.14.0_rev15-setup.exe