Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this pyd file not import on some computers?

Tags:

python

windows

My python project has a C++ component which is compiled and distributed as a .pyd file inside a Python egg. I've noticed that it seems to be incompatible with only some of our our brand new 64 bit Windows servers. We have 4 (allegedly) identically provisioned machines - each of them runs Windows 2003 server 64 bit edition, but 2 of these machines do not allow me to call functions in the egg.

After some experimentation I was able to find a recipe for producing a reproducible error. The problem seems to occur when Python tries to import the pyd file.

I copied the pyd to a temp folder and ran Python.exe from that location, incidentally we are still using the 32bit edition of Python 2.4.4 since none of our libraries have been ported to 64 bit architecture yet. Next I try to import my module (called pyccalyon). The first time I try this I get an error message:

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

Next time I try this the python interpreter crashes out: no stacktrace at all!

Naturally you are suspecting my PYD - the odd thing about this is that it's already in use on thousands of PCs and 10s of other servers, many of which are identical spec'd 64 bit machines. The project is continuously tested both in development and after release, so if this thing were so tinder-box unstable we'd have known about it a very long time ago. This component is considered to be stable code so it's surprising that it's breaking so spectacularly.

Any suggestions to what I can do to debug this troublesome library? Crazy ideas welcome at this point because we've exhausted all the sensible ones.

Thanks!

Update 0: Okay using Process monitor I was able to compare one 64bit server that fails with another that works just fine. I found that the breakage seems to occur due to a missing DLL, SysWOW64/mscoreee.dll - any idea what this component is and where I can get it? I can refer this back to our IT provisioning people who can install stuff.

like image 563
Salim Fadhley Avatar asked Apr 15 '09 11:04

Salim Fadhley


People also ask

What opens PYD files?

PYD files can be opened with Python Software Foundation Python that is available for Windows, Mac and Linux OS.

What type of file is pyd?

pyd file is a library file containing Python code which can be called out to and used by other Python applications. In order to make this library available to other Python programs, it is packaged as a dynamic link library.

How do I run a pyd file in Python?

pyd files are dll's , but there are a few differences. If you have a DLL named foo. pyd, then it must have a function PyInit_foo() . You can then write Python import foo , and Python will search for foo.

Is pyd a DLL?

Yes, . pyd files are dll's, but there are a few differences. If you have a DLL named foo.


2 Answers

You could try something like Process Monitor, to watch what DLLs it tries to load. I'd assume that one of the other DLLs it relies on can't be found.

Edit: It looks like you've already managed to get some useful info out of it, but I'll clarify how you could reduce the deluge of information that procmon produces.

Use the filter function to specify the command line (in this case, require that the command line contains python). This will show you messages only from the process you're interested in. Then you can filter out all success results, so you can see which DLL it's looking for.

Obviously there are lots of other things you can filter on, but this is how I've got results in the past. It's a really handy tool for working out what's going on in situations like this.

(Tools like depends or DependencyWalker are also good for finding out what DLLs a library relies on - they give the static information while procmon will show you the dynamic view. Both of them can be useful.)

like image 73
babbageclunk Avatar answered Nov 15 '22 21:11

babbageclunk


Have you tried checking which DLLs that PYD links? You can do that for example with either with Dependency Walker or VS's depends.exe.

like image 20
vartec Avatar answered Nov 15 '22 22:11

vartec