8

I installed the latest versions of python (2.6.5), gtk+, pygtk (and friends) from their respective websites on Windows XP SP3. When you try to import gtk (or just glib for that matter), an ImportError is raised:

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\lib\site-packages\gtk-2.0\gtk\__init__.py", line 38, in <module>
    import gobject as _gobject
  File "C:\Python26\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:\Python26\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.

This was working on the same machine around 6 months ago, although this time around I have re-installed. I tried different versions of the libraries but still couldn't get it to work.

There are a couple of pages out there relating to this, but not suggest a solution, and I'm unable to find one.

Jon
  • 9,815
  • 9
  • 46
  • 67

6 Answers6

5

I got a work around this by installing the windows GTK+ runtime as indicated in this link http://www.gramps-project.org/wiki/index.php?title=Windows_installer#Installation

Also see their page dedicated to troubleshooting import errors on windows: http://www.gramps-project.org/wiki/index.php?title=ImportError:_DLL_load_failed

matt wilkie
  • 17,268
  • 24
  • 80
  • 115
Oliver Nina
  • 655
  • 6
  • 4
3

I managed to solve this myself. Firstly, there can be more than one cause so this may not help everyone.

I went through the PATH system environment variable and removed all paths that pointed to old versions of gtk+ (for example, those that come packaged with applications).

Jon
  • 9,815
  • 9
  • 46
  • 67
2

Same problem, answer was to reinstall pygtk from grampy page. It was problem of pygtk, not system or gtk. (Before this, import pygtk works well)

Oleksandr
  • 86
  • 3
2

I had this same exact problem on Windows 7 64. I tried installing multiple versions of python 2.6, and the all-in-one pygtk that is supposed to give you GTK+ also. This installer didn't seem to do anything. Then I installed the latest versions of GTK+ (from binary), pygtk, pycairo, and gobject (all explained on the pygtk downloads website). When I did this, I got the ImportError: DLL load failed: The specified procedure could not be found. that is given above.

The SOLUTION was to uninstall pygtk, pycairo, gobject and remove the GTK+ bin location from my path variable. Then I went here and did the first 5 steps (in that order) under "Dependencies - The Hard Way". And now it works. Note: I didn't install gramps, just the pygtk part (first 5 steps).

jeffery_the_wind
  • 17,048
  • 34
  • 98
  • 160
0

I have copied gtk module (site-packages: gtk-2.0, pygtk.py, cairo) to other python installation and encountered the same problem.

It was happening because I forgot to copy site-packages/pygtk.pth.

rtxndr
  • 872
  • 1
  • 9
  • 20
0

Some reports indicate that the trick is to import pygtk first. Have you tried that?

detly
  • 29,332
  • 18
  • 93
  • 152