module search path

Discussion in 'Python' started by Ajay, Jul 30, 2004.

  1. Ajay

    Ajay Guest

    hi!

    I have the following directory structure.

    home
    user
    index.cgi
    common
    utils.py

    within index.cgi, import utils throws an errors.

    I did the following

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

    and then tried import common.utils and it still throws an error

    it works if i give the full path name to common and add that to sys.path as
    sys.path.append('/usr/hons/abrar1/lib/html/hons/um/home/common')

    My question is why doesn't it work when i add the path to the parent
    directory and try import common.utils?

    why doesn't that work?

    I dont want to rely on the full absolute path

    cheers

    ajay







    ----------------------------------------------------------------
    This message was sent using IMP, the Internet Messaging Program.
     
    Ajay, Jul 30, 2004
    #1
    1. Advertising

  2. Ajay

    angel Guest

    Should use sys.path.append('../common').

    sys.path.append('../')
    import common.utils
    is error.
    For the common is not a package. If you add a __init__.py in the directory
    common, above code will work.
     
    angel, Jul 30, 2004
    #2
    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. Stephen Ferg

    what is Python's module search path?

    Stephen Ferg, Jan 8, 2004, in forum: Python
    Replies:
    3
    Views:
    661
    Rene Pijlman
    Jan 9, 2004
  2. Ron Adam
    Replies:
    3
    Views:
    450
    Ron Adam
    Aug 2, 2005
  3. aznach
    Replies:
    1
    Views:
    246
    Thomas Guettler
    Oct 17, 2006
  4. Russ
    Replies:
    3
    Views:
    368
    Gabriel Genellina
    Feb 21, 2007
  5. Abby Lee
    Replies:
    5
    Views:
    428
    Abby Lee
    Aug 2, 2004
Loading...

Share This Page