473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

jython problem importing a py file

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 '06 #1
2 1933
<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

Feb 7 '06 #2
kz, you are my new hero :-)
thanks a bunch.

-Didier

Feb 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alexis Francart | last post by:
Hello, I want to use a program called maxq. This program is used for functionnal and regression test of web application. The language it uses is Jython. I need to get a part of a web page using...
5
by: Tennessee James Leeuwenburg | last post by:
Hi all, Sorry for the newb question, but Googling and FAQing didn't work. Is it correct that Jython can only access Java classes which are inside JAR archives in the JYTHON_HOME directory? IT...
6
by: Dave Benjamin | last post by:
Hey good people, I've been doing a lot of simultaneous Jython and CPython programming lately, and just wanted to say, with no intended ill will toward any of the individuals who have been...
1
by: rt lange | last post by:
I'm trying to get SciTE to run and compile my jython scripts. This is what I have in my python.properties file: command.name.1.*.py=Go Jython command.1.*.py=jython $(FileNameExt)...
10
by: Randall Smith | last post by:
I would like to use a type 4 JDBC driver in my Python program. I believe I can use in with Jython. Do you know of some way to communicate between the Jython and Python processes so that the...
6
by: py | last post by:
I want to serialize an object in jython and then be able to read it in using python, and vice versa. Any suggestions on how to do this? pickle doesnt work, nor does using ObjectOutputStream...
8
by: Mark Fink | last post by:
I try to port a server application to Jython. At the moment I use Jython21\Lib\socket.py Currently I do face problems with casting the string "localhost" to the desired value:...
2
by: donkeyboy | last post by:
All, I've tried the jythonc compiler to try and create an applet to see how it works, but I get a number of Java compile errors that are way above my knowledge. Does anyone know what any of the...
1
by: Benjamin | last post by:
When importing Java packages in Jython, what is the convention to simplify imports? For example: import java.util as util Is this correct? Or should I use from * import *?
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.