Trouble importing modules in IDLE (Win32)

Terry Reedy tjreedy at udel.edu
Fri Aug 22 16:43:27 EDT 2008



Diez B. Roggisch wrote:
> boblatest at googlemail.com schrieb:
>> Hello,

>> In short:
>> In a freshly (re)started shell, I can use "import odbc" by hand. I
>> can't import odbc from within a script, or by hand after trying to
>> start such a script. Screen capture follows.
>>
>> robert
>>
>>>>> ================================ RESTART 
>>>>> ================================
>>>>> import odbc # <<-no error here!
>>>>> ================================ RESTART 
>>>>> ================================
>>>>> # script started here
>>
>> Traceback (most recent call last):
>>   File "H:\PythonProjekte\ADBExpress.py", line 1, in <module>
>>     import odbc
>> ImportError: DLL load failed: Das angegebene Modul wurde nicht
>> gefunden.


> In both shell and idle, do
> 
>  >>> import sys
>  >>> print sys.prefix
> 
> Most probably these differ, and you need to install the odbc-module to 
> the python idle uses.

By shell, he means the IDLE shell.  But this is the direction to look 
first.  In the IDLE shell (3.0) those two lines give me the Python 
directory, the same as the command line interpreter.  When in a file 
that is *not* in that directory, ditto.

Bob, if you run a file that consists of the one statement 'import odbc', 
what happens.  If that works, then something in your script (or 
something it calls) is fiddling with sys.path or something.  Try to find 
a *minimal* file that exhibits the problem.

tjr




More information about the Python-list mailing list