473,287 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Trouble importing modules in IDLE (Win32)

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
>>================================ 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.
Aug 22 '08 #1
4 2259
bo*******@googlemail.com schrieb:
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
>>>================================ 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.

Diez
Aug 22 '08 #2


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

Aug 22 '08 #3
On Aug 22, 2:45 pm, "Diez B. Roggisch" <de...@nospam.web.dewrote:
boblat...@googlemail.com schrieb:
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
>>================================ 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.
No, they're the same:

IDLE 1.2.2
>>import sys
print sys.prefix
C:\Python25
>>>
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.
>>import sys
print sys.prefix
C:\Python25
>>>
Thanks,
robert
Aug 25 '08 #4
On Aug 22, 10:43 pm, Terry Reedy <tjre...@udel.eduwrote:
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
Aug 25 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul Dankoski | last post by:
Hello. I downloaded and installed Windows Python-2.3.exe. The install appears to be successful. There is a Start menu item showing "Python 2.3" --> "IDLE (Python GUI)". When I select this,...
1
by: Frans Englich | last post by:
Hello all, I have a couple of questions related to module importing. 1) When I start my Python program with `python foo.py` instead of simply adding a interpreter comment on the first line and...
3
by: Charles Krug | last post by:
List: I'm trying to use the example files from Programming Python, 2nd Ed. I've copied them into c:\Python24\Examples\PP2E. Launching any of the examples programs by themselves seems to work...
0
by: Brandon Metcalf | last post by:
I come from a Perl and C background and have been given an application written in Python to maintain and I know very little about Python. I'm having trouble at run time with importing modules. ...
6
by: rh0dium | last post by:
Hi all, Basically I have a bunch of pluggins in a directory (METDIR). For each one of these templated pluggins I want to do a specific routine. Let's start with a basic template file...
7
by: siggi | last post by:
Hi all, when I do >>>sys.path in IDLE (winXP), i get a horrendously long list of paths, paths I may have used during a lot of trials and errors. How can I clean up sys.path? I mean, trim it of...
0
Bulldog
by: Bulldog | last post by:
I have been playing around with this issue for a while and seen some previous posting trying to address the problem but I haven't seen any answers to the problem so I am reposting it in my quest for...
0
by: Martin P. Hellwig | last post by:
Hello all, I had some troubles in the past how to arrange my packages and modules, because I usually don't develop my stuff in the Lib\site-packages directory I have some troubles when importing...
4
by: Python | last post by:
Hi there, I moved a few modules into the modules folder (on OSX: /opt/local/lib/ python2.5/site-packages/). They don't show up though when I start IDLE... Is there a way to reload the modules...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.