[Python-Dev] Importing DLLs on Windows

Tim Peters tim.one@home.com
Mon, 23 Apr 2001 01:41:08 -0400


[MAL]
> Oh, sorry that I wasn't clear enough.

Me neither (see below).

> Referring to the mxNumber package, I am seeing this situation:
>
> # This works... (note the start directory)
>
> C:\WINDOWS>python
> Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> >>> import mx.Number
> >>> print mx.Number.Float(3.141)
> 3.14100000000000001421e+0
> >>>
>
> # This doesn't.... (from the Python install directory)
>
> D:\Python21>python
> Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> >>> import mx.Number
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "d:\python21\mx\Number\__init__.py", line 9, in ?
>     from Number import *
>   File "d:\python21\mx\Number\Number.py", line 11, in ?
>     from mxNumber import *
>   File "d:\python21\mx\Number\mxNumber\__init__.py", line 21, in ?
>     from mxNumber import *
> ImportError: DLL load failed: Ein der fnr die Ausfnhrung dieser
> Anwendung notwen dige Bibliothekdateien kann nicht gefunden werden.
> >>>

Well, there's your problem:  looks some German hackers got into your machine
and screwed up the OS <wink>.

Now let me clarify what I wrote before:  when I said I couldn't provoke a
problem, I meant ANY problem.  It didn't matter whether I used the
__init__.py you shipped, or used the two-liner I posted, and it didn't matter
whether I started Python 2.1 from the install directory or from C:\Code
(etc).  Nothing failed no matter what I tried.

The only thing I see different in what you did above is that your Python
install directory is on a different drive (D: instead of C:).  I only have
one drive here, so I can't do a good job of simulating that.  Best I can do
here is fake it via the DOS subst command:

K:\Python21>python
Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import mx.Number
>>> from mx.Number import *
>>>

Still no problem.  What happens if you install Python onto your C: drive
instead?  And if that does work for you, is it because of the C: drive, or
because you left some old development work on your D: drive that's confusing
things?

Do you have confirmation of your problem from anyone else?  Or are you the
only one who has bumped into it?

> ...
> Please try starting Python from your Python install dir and
> then do the import.

I already had, in the last msg.  And again above.

> BTW, I'm doing this on Windows 95 in case this matters (which I'm
> sure it does :-/).

Possibly, but can't say.  We need more data.

BTW, do you understand what your code does <0.7 wink>?  That is, there are
packages, modules *and* DLLs with the same base name, and "import *"
everywhere.  I've always stayed so far away from import end cases that I have
no idea what the rules are supposed to be when you live on the edge.  That
may have something to do with this too, although I can't see how (although
since I don't know what the rules are, that's a guess too!).