473,748 Members | 3,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1955
<didier.prophet e> 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=$T OP

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
5477
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 regular expression. However i try to import the RE library but i'm not able to. Since the Jython.jar already contains an ORO i tried to use it but without success. I then tried to import the RE library but was unable to do so. I then try to...
5
15662
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 doesn't seem to be documented. I ask because I want to do groovy prototyping using Jython, and save myself a lot of coding overhead to try something a little out-of-the-box. I have a working directory where all my code lives, and because my app is...
6
2109
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 generous enough to make the two languages possible, that, well, they're kinda different. I guess it was inevitable, but with Jython stuck at Python 2.1, it's not really the same language as CPython is today. You still have to type "from __future__...
1
2513
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) command.1.subsystem.*.py=1 command.name.2.*.py=Jython -> jar command.2.*.py=jythonc --core --jar $(FileName).jar $(FileNameExt) command.2.subsystem.*.py=1
10
2141
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 CPython program can use the Jython JDBC database connection? Randall
6
2165
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 (from jython). I prefer to do it file based ...something like pickle.dump(someObj, open("output.txt", "w"))
8
5999
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: D:\AUT_TEST\workspace\JyFIT>jython fit/JyFitServer2.py localhost 1234 23 localhost Traceback (innermost last): File "fit/JyFitServer2.py", line 146, in ?
2
2474
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 following means? I'm using JDK 1.5.0_09, under Win XP SP2. Runnnig the file " jython FILENAME" works, so I don't know what's happening. Any thoughts?
1
1135
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
9544
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8243
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.