sys.path

Discussion in 'Python' started by HMS Surprise, May 8, 2007.

  1. HMS Surprise

    HMS Surprise Guest

    Is sys.path setup differnently in jython vs python? I have environment
    variables pythonpath and jythonpath set to include C:\python22 but the
    initial printout indicates it is being ignored. Also when I used
    sys.path.extend, the added pathname shows up as a series of single
    characters. Have I misused .extend?

    Thanks,

    jh

    import sys
    print sys.path
    sys.path.extend("c:\python22")
    print sys.path
    import urllib



    ['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython']
    ['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython', 'c', ':', '\\', 'p',
    'y', 't', 'h', 'o', 'n', '2', '2']
    Traceback (innermost last):
    File "<string>", line 9, in ?
    ImportError: no module named urllib
    HMS Surprise, May 8, 2007
    #1
    1. Advertising

  2. HMS Surprise wrote:

    > Have I misused .extend?


    The .extend() method expects an iterable, try .append() instead.

    Cheers,

    --
    Klaus Alexander Seistrup
    http://klaus.seistrup.dk/
    Klaus Alexander Seistrup, May 8, 2007
    #2
    1. Advertising

  3. HMS Surprise

    HMS Surprise Guest

    On May 8, 10:40 am, Klaus Alexander Seistrup <> wrote:
    > HMS Surprise wrote:
    > > Have I misused .extend?

    >
    > The .extend() method expects an iterable, try .append() instead.
    >
    > Cheers,
    >
    > --
    > Klaus Alexander Seistruphttp://klaus.seistrup.dk/


    Thanks Klaus.

    That certainly cleaned up sys.path. Now if I can get the system to
    search there for my lib file.
    HMS Surprise, May 8, 2007
    #3
  4. HMS Surprise

    John Machin Guest

    On May 9, 1:35 am, HMS Surprise <> wrote:
    > Is sys.path setup differnently in jython vs python? I have environment
    > variables pythonpath and jythonpath set to include C:\python22 but the
    > initial printout indicates it is being ignored. Also when I used
    > sys.path.extend, the added pathname shows up as a series of single
    > characters. Have I misused .extend?
    >
    > Thanks,
    >
    > jh
    >
    > import sys
    > print sys.path
    > sys.path.extend("c:\python22")
    > print sys.path
    > import urllib
    >
    > ['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython']


    Your sys.path looks stuffed already. You may have missed this in the
    flurry of posts and counter-posts, but I asked: have you been messing
    with the PYTHONHOME environment variable?

    This is what sys.path looks like after a normal installation, before
    any messing about:

    C:\junk>set PYTHONPATH
    Environment variable PYTHONPATH not defined

    C:\junk>set PYTHONHOME
    Environment variable PYTHONHOME not defined

    C:\junk>\python22\python
    Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.path

    ['', 'C:\\junk', 'C:\\python22\\DLLs', 'C:\\python22\\lib', 'C:\
    \python22\\lib\\lib-tk', 'C:\\python22', 'C:\\python22\\lib\\site-
    packages']
    >>>


    To get urllib to be imported from c:\python22\lib\urllib.py, you need
    c:\python22\lib (NOT c:\python22) to be in sys.path, and it should
    ALREADY be in sys.path (if you are running Python 2.2, of course).

    Please go to a dos-prompt, type in what I did above and paste the
    results into your next post.
    John Machin, May 8, 2007
    #4
    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. Ronald Meier
    Replies:
    2
    Views:
    1,471
    Keith S.
    Oct 21, 2003
  2. Jeff Wagner

    sys.path.append('/my/new/path')

    Jeff Wagner, Nov 24, 2003, in forum: Python
    Replies:
    3
    Views:
    519
    Patrick Useldinger
    Nov 24, 2003
  3. Replies:
    3
    Views:
    387
  4. Roman Neuhauser
    Replies:
    0
    Views:
    648
    Roman Neuhauser
    Apr 4, 2005
  5. wen
    Replies:
    10
    Views:
    961
    Peter Hansen
    Aug 19, 2005
Loading...

Share This Page