Import gtk / glib produces ImportError: DLL loading error

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

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. 

It worked on the same machine about 6 months ago, although this time I installed it again. I tried different versions of the libraries, but could not get it to work.

There is a couple of pages where there is to this, but do not offer a solution, and I can not find it.

+7
python gtk pygtk
source share
6 answers

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

I went through the PATH system environment variable and deleted all the paths pointing to the old versions of gtk + (for example, those that are bundled with the applications).

+3
source share

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

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

+5
source share

Same problem, the answer was to reinstall pygtk from the grammar page. It was a pigtag problem, not a system or gtk. (Before that, pygtk import works well)

+2
source share

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

The SOLUTION was to remove pygtk, pycairo, gobject and remove the GTK + bin location from my path variable. Then I went here and took the first 5 steps (in that order) in the "Dependencies - Hard Way" section. And now it works. Note. I did not install grams, but only part of pygtk (first 5 steps).

+2
source share

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

0
source share

I copied the gtk module (site-packages: gtk-2.0, pygtk.py, cairo) to another python installation and ran into the same problem.

This happened because I forgot to copy the site packages / pygtk.pth.

0
source share

All Articles