ImportError: DLL load failed: The specified module could not be found, SWIG, life, etc

Bill Davy Bill at SynectixLtd.com
Mon Jul 5 10:35:59 EDT 2010


I am struggling :-(



I have used SWIG to build a module called SHIP.  So I have a directory 
containing SHIP.py and _SHIP.pyd, as follows:



H:\Viper\HostPC\V1\SHIP\Release>dir

 Volume in drive H has no label.

 Volume Serial Number is B83B-76F2



 Directory of H:\Viper\HostPC\V1\SHIP\Release



05/07/2010  14:43    <DIR>          .

05/07/2010  14:43    <DIR>          ..

03/07/2010  16:28            41,079 SHIP.py

03/07/2010  14:36           495,616 _SHIP.pyd

               2 File(s)        536,695 bytes

               2 Dir(s)  58,270,535,680 bytes free







I have a test Python program which imports sys and os and then attempts to 
import SHIP; it begins as follows:





## D for John's notebook

## E for Rod's notebook

## H for Bill's notebook

DRIVE = 'H:'



import sys

import os

if ( not os.path.exists(DRIVE) ):

    print "Drive \'%s\' does not exist on this machine; edit top of file" % 
(DRIVE)

    sys.exit(0)



# Prepend our path

sys.path[:0] = [DRIVE + r'\Viper\HostPC\V1\SHIP\Release']



import SHIP



SHIP.Initialise();





I then create a Command Prompt window and enter:





H:\Viper\HostPC\V1\SHIP>C:\Python26\python -vv Test1.py >tmp.txt 2>&1



In tmp.txt, I see the following:



<snipped out lots of importing>

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.

# trying H:\Viper\HostPC\V1\SHIP\Release\SHIP.pyd

# trying H:\Viper\HostPC\V1\SHIP\Release\SHIP.py

# H:\Viper\HostPC\V1\SHIP\Release\SHIP.pyc matches 
H:\Viper\HostPC\V1\SHIP\Release\SHIP.py

import SHIP # precompiled from H:\Viper\HostPC\V1\SHIP\Release\SHIP.pyc

# trying H:\Viper\HostPC\V1\SHIP\Release\_SHIP.pyd

#   clear[2] __name__

#   clear[2] __file__

Traceback (most recent call last):

  File "Test1.py", line 15, in <module>

    import SHIP

  File "H:\Viper\HostPC\V1\SHIP\Release\SHIP.py", line 7, in <module>

    import _SHIP

ImportError: DLL load failed: The specified module could not be found.

<snip>



It would seem the "import SHIP" is finding SHIP.py without any trouble.

SHIP.py begins by "import _SHIP".

Python appears to find H:\Viper\HostPC\V1\SHIP\Release\_SHIP.pyd but for 
some reason, which I cannot fathom, says "DLL load failed".



Can anyone offer me any suggestion where I am going wrong or how to tackle 
this problem?



Could it be that the Python 2.6 I am running did not use the same compiler 
(VC6) with which I buiult _SHIP.pyd and if so, is there a way round this 
without moving on from VC6?



TIA,

   Bill





More information about the Python-list mailing list