ImportError: DLL load failed

From Gramps
Revision as of 04:27, 27 November 2010 by Steve geo (talk | contribs) (Add info on a minal test displaying ImportError: DLL load failed)
Jump to: navigation, search

Problem Description

On Windows GRAMPS is usually started from the menu entry or a short cut to the same location, that is fine when everything is working fine. When your system is experiencing the problem described here, trying to start GRAMPS will cause the GRAMPS GUI to never appear, and you will get no user information back about the problem.

The only visibility to the actual problem will be when you start GRAMPS from the command prompt, in that case you will get the error message from python similar to the following:

C:\Program Files\gramps>"c:\Python26\python.exe"
483: ERROR: line 138: Unhandled exception
Traceback (most recent call last):
  File "", line 188, in <module>
    errors = run()
  File "", line 179, in run
    from gui.grampsgui import startgtkloop
  File "C:\Program Files\gramps\gui\", line 53, in <module>
    import gtk
  File "c:\Python26\lib\site-packages\gtk-2.0\gtk\", line 48, in <module>
    from gtk import _gtk
ImportError: DLL load failed: The specified procedure could not be found.

What is happening is that python is trying to load the Gtk runtime, when python is unsuccessful loading the runtime, it will throw and exception and dump the above trace out. There can be many reasons why python cannot load the gtk-runtime.

Now it is up to the user to diagnose what is wrong with his/her system and rectify it. Unfortunately since there have been multiple causes for the error in the past this can be quite difficult resulting in potential GRAMPS users to throw their hands up in disgust and give up, this page is solely to discuss possible methods to identify and fix the above problem.

In the above example, python tried to start GRAMPS this is a complicated test case, so I'd like to try and simplify it to a minimal test case that exhibits the same behaviour. This minimal test case can then be used when testing if changes to the environment have had any effect on the problem. The minimal test case does not even use GRAMPS.

Minimal Test Case

Simply start a windows command prompt.


How to start Python 2.6 command line on Windows XP using the Start Menu
Start -> All Programs-> Python 2.6 -> Python (Command Line)

Once the command prompt has started type import gtk in the command prompt window.

Python 2.6.3 (r263rc1:75186, Oct  2 2009, 20:40:30) [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\", line 48, in <module>
    from gtk import _gtk
ImportError: DLL load failed: The specified procedure could not be found.

If your minimal test throws the exception as shown you have just proved the problem exists between python and gtk-runtime, this is not a GRAMPS problem. How you proceed from here is dependent on your own skill set and how dirty you are willing to get your hands.

check_gtk_install was an attempt to create a script to help diagnose problems with the gtk install, it has been of limited success, sometimes helping, sometimes confusing more. Possibly the biggest problem, is that the output of the script can be cryptic and can need someone with prior knowledge to decode it.

the check script benefits from a couple of other third party components to be downloaded as well

  • Win32Api Provides some ability to handle dos short path names that might be encountered in the path environment variable. This is a python library, download and install as you would any python library.
  • Dependency Walker Most importantly this program analyses and executable/DLL it is excellent for identifying missing DLL's. This is a zip file, download and expand the contents into the same directory that you will put the script

You will need to download,

Run the script from the command line and check (or post online in the GRAMPS Windows forum) the output of the script.

Note; The DependencyWalker section may post a number of issues, that can safely be ignored.

dependency walker

I want to discuss how to use dependency walker on it's own to achieve the same aim.