python无法在电脑上运行,无法在Windows上运行python。我错过了什么?

I am pretty new to python. Please correct me if I show stupidity.

So I am trying to run the following code:

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()

And I get the following error

** (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

from gi.repository import Gtk

File "", line 2237, in _find_and_load

File "", line 2226, in _find_and_load_unlocked

File "", line 1191, in _load_unlocked

File "", 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

>

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

I am running Windows 8 on 64 bit.

Below are my installations to develop a Gtk based GUI.

What am I missing or doing wrong ?

Please help. (thanks in advance)

解决方案

I just had the same kind of problem.

To solve it, I have installed GTK3+ from

http://www.gtk.org/download/win32.php

the all-in-one bundle of the GTK+ stack including 3rd-party dependencies

at http://win32builder.gnome.org/gtk+-bundle_3.6.4-20130921_win32.zip

after unzip the file in somedir.

You can test it by running somedir\bin\gtk3-demo.exe

you have to add the bin dir which contains dll files in the windows PATH

run in console > where libgdk-3-0.dll to check dll are found then run your python file.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值