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

B

Bill Davy

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
 
T

Thomas Jollans

I am struggling :-(
smile!


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

[ ...]

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

Maybe it doesn't mean _SHIP.pyd, but another DLL: maybe _SHIP.pyd
depends on some other DLL? Since you used SWIG, I'm guessing that you're
wrapping some other library. Maybe that's what it can't find.
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?

Shouldn't be a problem, as long as the calling convention hasn't change,
which it hasn't. If you're on a 64-bit system there might be a problem
there with Python and some DLLs being built for different architectures?

Cheers,
Thomas
 
B

Bill Davy

Thomas Jollans said:
I am struggling :-(
smile!


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

[ ...]

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

Maybe it doesn't mean _SHIP.pyd, but another DLL: maybe _SHIP.pyd
depends on some other DLL? Since you used SWIG, I'm guessing that you're
wrapping some other library. Maybe that's what it can't find.

Well, there's no mention of another librarary, and "import _SHIP" is the
first (non-comment) statement in SHIP.py
But when I run Dependency Walker against _SHIP.pyd it does say there's a
missing DLL (WINUSB.DLL) so I suspect I've got to sort that out.
Shouldn't be a problem, as long as the calling convention hasn't change,
which it hasn't. If you're on a 64-bit system there might be a problem
there with Python and some DLLs being built for different architectures?

Yep, all for the same architetcure. I suspect it's a dependency problem.
Oh well.
 
Joined
Jul 27, 2011
Messages
1
Reaction score
0
Here are the steps to replace winusb.dll file

Hello,

As winusb.dll file is missing or corrupted, you need to get a new dll file. Here are the steps to replace winusb.dll file

Step 1. You can download missing winusb.dll here:

http://dllcentral.com/winusb.dll/6.0.6000.16386/

Step 2. Paste this file into your system32 or SyWOW64 folder.

Step 3. Navigate to your System32(32Bit OS) or SyWOW64(64Bit OS) Folder.

Note: The location of System32 and SyWOW64 is
C:Windows\System32 (If you are using 32Bit Windows)
C:\Windows\SysWOW64 (if you are using 64Bit Windows)

Step 4. Paste the winusb.dll file into this folder.

Step 5. Try to run it. It might work now. If not, restart your computer to restore it effectively.

Good Luck :lol:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top