473,699 Members | 2,364 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 1951
<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
5473
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
15659
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
2106
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
2507
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
2136
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
2160
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
5993
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
2471
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
8687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9174
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
9035
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
8884
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7751
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...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
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
3
2009
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.