How do I install PyGTK / PyGobject on Windows with Python 2.6?
Asked Answered
M

5

12

I have an application which depends on PyGTK, PyGobject, and PyCairo that I built to work on Linux. I want to port it over to windows, but when I execute import gobject I get this:

Traceback (most recent call last):
    import gobject
  File "C:\Python26\lib\site-packages\gtk-2.0\gobject\__init__.py", line 30, in <module>
    from gobject.constants import *
  File "C:\Python26\lib\site-packages\gtk-2.0\gobject\constants.py", line 22, in <module>
    from _gobject import type_from_name
ImportError: DLL load failed: The specified procedure could not be found.

This appears to be caused by the switch from building using MinGW to Microsoft Visual Studio, as documented Python Bug 3308 (closed: wontfix).

Is there any way to install PyGTK/PyGObject in a way that will work with Python 2.6 on Windows, without having to recompile one or the other from source?

Minnaminnaminnie answered 18/8, 2009 at 14:31 Comment(0)
S
10

I have it working fine, and it didn't give me much trouble, so we know it can be done...

Keep in mind you will probably need all of the following installed on your Windows machine:

I suspect in your case that the PyGTK libraries are not finding your GTK+ Runtime directory where the DLLs are. You should have the environment variable GTK_BASEPATH set to the directory of your GTK+ Runtime (usually C:\GTK).

Please also see the PyGTK-on-Windows FAQ

Now, if you're trying to compile the PyGTK'ed Python with Py2EXE, that's a bit more complicated, but it can be done as well...

Shoelace answered 18/8, 2009 at 14:44 Comment(3)
ewall: Why reference is only for 32-bit? How do we do the same for 64-bit windows 7 or windows 8? Can you share please (cause in google search your link appears on result often) - ftp.gnome.org/pub/GNOME/binaries/win64?Underset
@YumYumYum: Alas, my answer is now over 4 years old, and approximately 2 months before Windows 7 was even released to the public! I don't recall if since then I've even tried to get the old Python 2.6 working on a newer x64 Windows, so I'm not too qualified to comment... but I can certainly add the x64 download links to the post, with the usual YMMV disclaimer. Also note digitalPBK's answer below. :)Shoelace
without PyGobject, I will have C runtime error when I try to install PyCairo, thanks for the hints to lead me install PyGobject and solve my installation problem.Solarium
O
4

The PyGTK all-in-one installer has been updated recently:

http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/

This will install PyGTK, PyGObject, PyCairo, PyGtkSourceView2, PyGooCanvas, PyRsvg, the gtk+-bundle and Glade. It is absolutely everything necessary to be able to successfully import gobject, import gtk, etc, without DLL problems.

Oily answered 18/3, 2011 at 20:31 Comment(0)
G
3

for 64 bit Windows users see

http://digitalpbk.blogspot.in/2012/03/installing-pygtk-pypango-and-pycairo-on.html

Above steps will give Invalid DLL error on 64 bit.

Gershwin answered 30/3, 2012 at 17:15 Comment(0)
L
1

u should have pygtk,pycairo,pygboject and the gtk+ runtime...

see this for an all in one installer http://aruiz.typepad.com/siliconisland/2006/12/allinone_win32_.html

Layamon answered 2/1, 2010 at 19:15 Comment(0)
R
0

Be careful about installing PyGTK bundle pack if any one planning to run PyGTK through embedded interpreter and the C/C++ code is already using GTK. PyGTK bundle pack does not add its GTK runtime to PATH.

In such case possibly the C code will take GTK from PATH (as probably you have already installed GTK bundle pack) and Python will use separate set of GTK runtime libraries.

Therefore in my case either C GUI or Python GUI used to run properly and used to conflict while running together.

As I use Psychopy as my base python collection, to solve this problem I have just installed PyGTK PyGTK, Pycairo, Pygobject on top of Psychopy.

Apart from using only one set of GTK runtime I had to initialize GTK in my C code through PyGTK (not by gtk_init (&argc, &argv) in my C code) after initializing python interpreter.

Ravin answered 24/1, 2015 at 4:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.