How can this script fail?

M.-A. Lemburg mal at egenix.com
Wed Aug 27 07:08:22 EDT 2008


On 2008-08-27 12:37, boblatest at googlemail.com wrote:
> 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:

I don't think this is related to IDLE or your setup. The odbc
module is very old and unmaintained, so it's possible that Windows
doesn't find some system DLLs needed for it to work.

If you're looking for a reliable Python ODBC interface, I'd suggest
you have a look at our mxODBC:

    http://www.egenix.com/products/python/mxODBC/

If you're just using the odbc module as an example, I'd suggest
you try some other extension modules as well, esp. ones which don't
have external dependencies.

> ----------------------------------
> 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>

This looks strange... the same module in two dirs that only
differ by case ?

Note that the standard location is C:\Python25\Lib\site-packages
(with capital 'L').

> 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
> --
> http://mail.python.org/mailman/listinfo/python-list

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Aug 27 2008)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611



More information about the Python-list mailing list