473,396 Members | 1,707 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,396 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 2267
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.