Trouble importing modules in IDLE (Win32)

B

boblatest

Hello,

I wrote aprogram that imports odbc and dbi. Originally I used PyWin,
but now I prefer IDLE for working in Windows. Anyway, when I start my
program from IDLE, it can't import the odbc and dbi modules. However,
when I restart the shell and type "import odbc" at the prompt by, I
don't get an error. When I try to run the program now, I get the error
again. When I now type "import odbc" at the prompt, I get the error as
well.

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

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

Diez B. Roggisch

Hello,

I wrote aprogram that imports odbc and dbi. Originally I used PyWin,
but now I prefer IDLE for working in Windows. Anyway, when I start my
program from IDLE, it can't import the odbc and dbi modules. However,
when I restart the shell and type "import odbc" at the prompt by, I
don't get an error. When I try to run the program now, I get the error
again. When I now type "import odbc" at the prompt, I get the error as
well.

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


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

Most probably these differ, and you need to install the odbc-module to
the python idle uses.

Diez
 
T

Terry Reedy

Diez said:
In both shell and idle, do


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
 
B

boblatest

(e-mail address removed) schrieb:







In both shell and idle, do


Most probably these differ, and you need to install the odbc-module to
the python idle uses.

No, they're the same:

IDLE 1.2.2
PythonWin 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin'
for further copyright information.
Thanks,
robert
 
B

boblatest

Diez B. Roggisch wrote:
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

Hello Dietz,

1. The output of "print sys.prefix" is the same in both shells (see my
other posting).
2. The minimal file that exhibits the problem (in IDLE but not in
PythonWin) is one that consists of the single line "import odbc".

Thanks,
robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top