Newbie question: WinNT Python 1.5.2 - import seems not to work the way I expect
Parzival
parz at RemoveThisSpamBucket.home.com
Tue Oct 24 17:00:06 EDT 2000
I am running Python 1.5.2 on Win NT 4.0.
I am trying to explore the "dopy" distributed object module, and the modules
fail with import errors. I tried to reduce this problem to its simplest
manifestation, and found that I got one result in IDLE, and another running
my test module from the command prompt. The contents of "dopy" directory
are:
F:\Program Files\Python\dopy>ls
Manual.html __init__.py dopy.pyc naming.pyc tb.pyc
Manual.nml __init__.pyc dopyclient.py pos.py tcp.py
README.html backup dopyserver.py pos.pyc tcp.pyc
README.txt dopy.py naming.py tb.py testimp.py
The test script "testimp.py" reads:
import sys
print sys.path
from dopy import tcp
The output of the script (the news client may split the lines):
F:\Program Files\Python\dopy>testimp.py
['F:\\PROGRA~1\\Python\\dopy', 'F:\\PROGRA~1\\Python', 'F:\\Program
Files\\Python\\Lib\\plat-win', 'F:\\Program Files\\Python\\Lib',
'F:\\Program Files\\Python\\DLLs', 'F:\\Program Files\\Python\\Lib\\lib-tk',
'F:\\Program Files\\Python', 'F:\\Program Files\\Python\\DLLs', 'F:\\Program
Files\\Python\\lib', 'F:\\Program Files\\Python\\lib\\plat-win',
'F:\\Program Files\\Python\\lib\\lib-tk', 'F:\\Program Files\\Python']
Traceback (innermost last):
File "F:\PROGRA~1\Python\dopy\testimp.py", line 3, in ?
from dopy import tcp
ImportError: cannot import name tcp
When running the Python command prompt, the same commands produce the
following output:
Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import sys
>>> print sys.path
['', 'F:\\PROGRA~1\\Python', 'F:\\Program Files\\Python\\Lib\\plat-win',
'F:\\Pr
ogram Files\\Python\\Lib', 'F:\\Program Files\\Python\\DLLs', 'F:\\Program
Files
\\Python\\Lib\\lib-tk', 'F:\\Program Files\\Python', 'F:\\Program
Files\\Python\
\DLLs', 'F:\\Program Files\\Python\\lib', 'F:\\Program
Files\\Python\\lib\\plat-
win', 'F:\\Program Files\\Python\\lib\\lib-tk', 'F:\\Program Files\\Python']
>>> from dopy import tcp
>>>
I.e. the commands found in the script succeed.
When I load testimp.py in the IDLE editor, and run it I get:
['F:\\PROGRA~1\\Python\\Tools\\idle', 'F:\\PROGRA~1\\Python', 'F:\\Program
Files\\Python\\Lib\\plat-win', 'F:\\Program Files\\Python\\Lib',
'F:\\Program Files\\Python\\DLLs', 'F:\\Program Files\\Python\\Lib\\lib-tk',
'F:\\Program Files\\Python', 'F:\\Program Files\\Python\\DLLs', 'F:\\Program
Files\\Python\\lib', 'F:\\Program Files\\Python\\lib\\plat-win',
'F:\\Program Files\\Python\\lib\\lib-tk', 'F:\\Program Files\\Python']
I.e. the script also succeeds. So, my question is why do I get this
import failure when running testimp.py from the command prompt?
- Parzival
More information about the Python-list
mailing list