IDLE Path doesn't include current dir after chdir

Tom McDavid tmcdavid at yahoo.com
Thu May 13 02:20:44 EDT 2004


I'm trying to learn more Python and have come across a strange
behavior.
I have Python2.3 installed on a Win2K machine.  If I start the python
command line, I can do the following:
Python 2.3.2 (#49, Oct  2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getcwd()
'C:\\Python23'
>>> os.chdir('d:\\python')  
>>> os.getcwd()
'd:\\python'
>>> import fibo 
 
## fibo is fibonacci example from tutorial.
Everything works fine.  But with IDLE, I get the following:

Python 2.3.2 (#49, Oct  2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)]
on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************
    
IDLE 1.0      
>>> import os
>>> os.getcwd()
'C:\\Python23'
>>> os.chdir('d:\\python')
>>> os.getcwd()
'd:\\python'
>>> import fibo

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in -toplevel-
    import fibo
ImportError: No module named fibo
>>> 
 When I use a desktop shortcut that has my start directory as
d:\python rather than the default, I can import my modules and things
work reasonably.  I get the same "can't find module" result from
wxPython's PyAlaMode shell.
I dug a little and found that sys.path in idle doesn't seem to contain
".", when I manually added it, import behaves itself in idle after
chdir, but I don't want to have to manually fix my path every time I
start up.   Anyone have more insight or a fix?
Thanks,
Tom McDavid



More information about the Python-list mailing list