jython problem importing a py file

Discussion in 'Python' started by didier.prophete@gmail.com, Feb 7, 2006.

  1. Guest

    Ok, so I know this is probably a common jython error, but somehow I
    can't seem to find an answer to this trivial problem.

    Ok, I have the following (simple) directory structure:
    $TOP/
    __init__.py
    py_dir/
    __init__.py
    util.py

    I have:
    PYTHONPATH=$TOP
    CLASSPATH=$TOP

    I am now trying to execute the simple python/jython statement: "import
    py_dir.util"
    If I do a 'cd $TOP' first, then this works fine in python and jython.

    But if I do a 'cd $TOP/py_dir', then it still works fine in python, but
    jython gives me:
    Traceback (innermost last):
    File "<console>", line 1, in ?
    ImportError: No module named util

    I tried everything I could think of (playing with the __init__.py, the
    PYTHONCLASS, the CLASSPATH), but nothing seems to work...

    I am doing something wrong here ?

    -Didier
    , Feb 7, 2006
    #1
    1. Advertising

  2. <didier.prophete> writes:

    >
    > I tried everything I could think of (playing with the __init__.py, the
    > PYTHONCLASS, the CLASSPATH), but nothing seems to work...
    >
    > I am doing something wrong here ?
    >
    > -Didier
    >


    Take a look at the jython registry setting python.path:

    http://www.jython.org/docs/registry.html

    So if you invoke jython with say:

    jython -Dpython.path=$TOP

    your import should work.

    - kz
    Khalid Zuberi, Feb 7, 2006
    #2
    1. Advertising

  3. Guest

    kz, you are my new hero :)
    thanks a bunch.

    -Didier
    , Feb 7, 2006
    #3
    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. Alexis Francart

    importing re in Jython

    Alexis Francart, Jul 9, 2003, in forum: Python
    Replies:
    2
    Views:
    295
    Alan Kennedy
    Jul 9, 2003
  2. David McNab
    Replies:
    0
    Views:
    483
    David McNab
    Apr 9, 2004
  3. Divya Prakash
    Replies:
    0
    Views:
    428
    Divya Prakash
    Dec 19, 2006
  4. Pinegar, Kent T

    FW: [Jython-users] Jython Licensing Question

    Pinegar, Kent T, Jul 24, 2008, in forum: Python
    Replies:
    0
    Views:
    346
    Pinegar, Kent T
    Jul 24, 2008
  5. Gubatron
    Replies:
    2
    Views:
    562
    Gubatron
    Dec 3, 2008
Loading...

Share This Page