Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > jython problem importing a py file

Reply
Thread Tools

jython problem importing a py file

 
 
didier.prophete@gmail.com
Guest
Posts: n/a
 
      02-07-2006
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

 
Reply With Quote
 
 
 
 
Khalid Zuberi
Guest
Posts: n/a
 
      02-07-2006
<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

 
Reply With Quote
 
 
 
 
didier.prophete@gmail.com
Guest
Posts: n/a
 
      02-07-2006
kz, you are my new hero
thanks a bunch.

-Didier

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Jython: Packing several .py on .jar, problem importing .py moduleswithin the .jar Gubatron Python 2 12-03-2008 06:01 PM
FW: [Jython-users] Jython Licensing Question Pinegar, Kent T Python 0 07-24-2008 01:38 PM
FW: [Jython-users] ERROR : parsing xml in jython Divya Prakash Python 0 12-19-2006 02:49 PM
[Jython-users] ANN: SPIRO - a cPython->Jython bridge (amongst otheruses) David McNab Python 0 04-09-2004 10:20 AM
importing re in Jython Alexis Francart Python 2 07-09-2003 12:11 PM



Advertisments