IDLE Path doesn't include current dir after chdir

Discussion in 'Python' started by Tom McDavid, May 13, 2004.

  1. Tom McDavid

    Tom McDavid Guest

    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
     
    Tom McDavid, May 13, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yun Mao

    os.environ and os.path.chdir

    Yun Mao, Sep 20, 2003, in forum: Python
    Replies:
    4
    Views:
    445
    Thomas Bellman
    Sep 20, 2003
  2. Tim Kynerd
    Replies:
    12
    Views:
    277
    Yukihiro Matsumoto
    Nov 28, 2003
  3. Joel VanderWerf

    Dir.chdir '~'

    Joel VanderWerf, Jan 3, 2004, in forum: Ruby
    Replies:
    2
    Views:
    159
    Joel VanderWerf
    Jan 3, 2004
  4. Père Noël

    Dir.chdir("..") versus `cd ..`

    Père Noël, Dec 11, 2006, in forum: Ruby
    Replies:
    6
    Views:
    126
    Père Noël
    Dec 11, 2006
  5. vulpes
    Replies:
    3
    Views:
    130
    vulpes
    Mar 21, 2007
Loading...

Share This Page