GTK import error

I am running Python 2.7 with the latest GTK installed.

I am trying to import gtk with the following line of code:

import gtk 

Throws the following error:

Traceback (last last call): File "C: \ GTKTutorial \ tutorial.py", line 3, in import gtk File "C: \ Python27 \ lib \ site-packages \ gtk-2.0 \ gtk__init __. Py", line 40 , in from gtk import _gtk ImportError: Error loading DLL: the specified procedure was not found.

How to fix it? import pygtk works and I have Glade 3.8.0 installed.

+4
source share
2 answers
+3
source

I just spent 3 days debugging this problem on my computer. This problem can have many root causes, because importing gtk actually causes a large number of DLLs to load. If any of them fails, you will receive the same error message. For me, the breakthrough was

http://www.dependencywalker.com/

which I used to profile the team

python -i -c "import gtk"

On my computer, the wrong version of zlib1.dll was in the system32 directory, which prevented it from loading correctly in gtk \ bin. And this happened, although the first entry in my path pointed to gtk \ bin.

I uninstalled zlib1.dll from system32 (the application that deserved it there to die) and the import worked fine. Your problem may be different, but the dependent walker can probably give you a hint about what is going wrong.

Windows may have other reasons for loading a DLL other than the one you put in your directory or path. I found a blog

http://www.davidlenihan.com/2007/07/winsxs.html

useful. It describes Microsoft's solution for managing many versions of a DLL and how to troubleshoot it.

+2
source

All Articles