How can this script fail?

boblatest at googlemail.com boblatest at googlemail.com
Wed Aug 27 12:37:30 CEST 2008


Hello,

it's still me, being unable to load certain modules (for instance,
odbc) in scripts that run though IDLE. I've now written a self-
containing script that illustrates the whole problem:

----------------------------------
import sys, os

# find odbc module in Python distribution tree:
for root, dirs, files in os.walk(sys.prefix):
    for fname in files:
        if fname[0:4] == 'odbc':
            libdir = root
            libname = fname
            print "Got file <%s> in dir <%s>" % (libname, libdir)

# Now we've probably found an odbc module. Let's see if its containing
dir is in the path:
# (Case shouldn't matter)
for pdir in sys.path:
    if pdir.lower() == libdir.lower():
        print "Found in path:"
        print "<%s>\n<%s>" % (libdir, pdir)

try:
    import odbc
except:
    print "But I still couldn't load %s:" % libname
    raise
----------------------------------
When this script is run, it produces the following output:

----------------------------------
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************

IDLE 1.2.2
>>> ================================ RESTART ================================
>>>
Got file <odbc.pyd> in dir <C:\Python25\Lib\site-packages\win32>
Found in path:
<C:\Python25\Lib\site-packages\win32>
<C:\Python25\lib\site-packages\win32>
But I still couldn't load odbc.pyd:

Traceback (most recent call last):
  File "D:\Documents and Settings\nxp10225\Desktop\test.py", line 17,
in <module>
    import odbc
ImportError: DLL load failed: Das angegebene Modul wurde nicht
gefunden.
>>> ================================ RESTART ================================
>>> import odbc
>>>
--------------------------------------------------
Note that after restarting the shell, I can manually import odbc via
keyboard.

Thanks,
robert



More information about the Python-list mailing list