473,587 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:\PythonProje kte\ADBExpress. py", line 1, in <module>
import odbc
ImportError: DLL load failed: Das angegebene Modul wurde nicht
gefunden.
Aug 22 '08 #1
4 2276
bo*******@googl email.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:\PythonProje kte\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*******@googl email.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:\PythonProje kte\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.w eb.dewrote:
boblat...@googl email.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:\PythonProje kte\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.e duwrote:
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
2776
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, nothing appears on my Windows 2000 screen. However, if I look at the task manager, I see "pythonw.exe", which I assume applies that the process is indeed running. I expect some sort of GUI to open.
1
1619
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 do `./foo.py`, some "local" imports fails, I guess because current working directory is different. Is CWD the only difference between running `python foo.py` and `./foo.py`? What is the recommended way? (I guess security is one aspect that can...
3
1839
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 spiffily. Using regedit, I appended "c:\Python24\Examples\PP2E" to Pythonpath
0
1078
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. Specifically, in several places time.strptime() is being used and Freeze is being used to produce binaries for each platform where this application runs. _strptime.py is also being supplied with the binaries. The first problem I encountered...
6
1406
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 example1.py ---------------- class example1: def __init__(self):
7
12727
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 unnecessary paths? So far, I know only the command >>>sys.path.append(r'c:....etc...'), but how to delete or insert at the beginning of the list, I know not. Thanks,
0
1170
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 a solution. I am using python 2.2.3, because I am using some dSpace software (controldesk/automationdesk) that is based upon that version of python. I have some pre-compiled python modules that come with the dspace applications. I am pretty sure...
0
1513
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 depending modules that are in 'sibling' directories. Like in the following scenario: pkg_root\ -__init__ - common\ - - __init__
4
1964
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 folders in sys.path without logging out and back in? something like "source .cshrc" in a shell...
0
7924
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8349
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6629
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.