tags:

views:

293

answers:

3

here's the deal.

i'm using MinGW to build a pythonC module using Swig. when i tell python to load the module, it fails and complains that python cannot find the module.

the funny thing is that the module is in the same directory (cwd) that i'm running python under and the module is named _mod.pyd. (i also have the generated mod.py file that uses _mod.pyd in the same path)

it's frustrating like you wouldn't believe!

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mod.py", line 25, in <module>
    _mod = swig_import_helper()
  File "mod.py", line 21, in swig_import_helper
    _mod = imp.load_module('_mod', fp, pathname, description)
ImportError: DLL load failed: The specified module could not be found.

it builds cleanly (i'm using distutils) and all my dll's are located in a directory that has been exposed to PATH.

i'm on a windowsxp+MinGW platform (latest stable MinGW).

thanks!

+1  A: 

This is a common problem, you probably are using the binary version of python for windows wich is compiled with msc not with Mingw. You can see it with ease looking what the interpreter says when you run it from command line. If it is the case you have to choices: compile the module with msc or compile python interpreter with Mingw, For the latter options, well, good look I never been able to do it!

FxIII
i've heard about this type of problem before. quite the bummer. i'll probably just do a recompile of python with mingw.
ct
recompile the python with mingw may be a big pain, if your will success please leave a comment :D
FxIII
A: 

I ran across this article on the MinGW site under "How do I create Python extensions?"

http://www.mingw.org/wiki/FAQ

I knew there was a trick with pexports but, I've tested this out a couple of times with little/no success (that I can remember). Has anyone else been able to make that successfully work?

cheers,

ct

update

I also found this tutorial -> http://boodebr.org/main/python/build-windows-extensions And this tutorial -> http://www.mail-archive.com/[email protected]/msg04655.html

I think it could be as easy as running: "setup.py build -c mingw32"

ct
A: 

Did you try:

python setup.py build --compiler=mingw32

?

FxIII
I gave that a spin and it didn't quite work out the way I had expected. thanks though! pexports worked and it turns out there was a shared library (dll) that wasn't in %PATH% so the windows "loader" was freaking out.
ct