问题
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 <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
I am running Windows 8 on 64 bit
.
Below are my installations to develop a Gtk based GUI.
python-3.4.3.amd64.msi
from https://www.python.org/downloads/windows/pygi-aio-3.14.0_rev10-setup.exe
from http://sourceforge.net/projects/pygobjectwin32/files/
What am I missing or doing wrong ? Please help. (thanks in advance)
回答1:
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.
回答2:
Just had the same issue (Although with a different version), Previous release doesn't have this problem.
Works: pygi-aio-3.14.0_rev15-setup.exe
Doesn't Work: pygi-aio-3.14.0_rev16-setup.exe
http://softlayer-dal.dl.sourceforge.net/project/pygobjectwin32/pygi-aio-3.14.0_rev15-setup.exe
来源:https://stackoverflow.com/questions/28735086/cannot-run-python-on-windows-what-am-i-missing