|
From: Seshu N. <ses...@sd...> - 2001-01-03 20:14:26
|
Hi, I'm not able to import "glob" module or "re" module for use in jython. I'm using jython-2.0a2. Is it a bug or a current limitation? Thanks, Seshu |
|
From: Ivan K. <iv...@ko...> - 2001-01-03 20:43:01
|
module "re" seems to be working fine for me. ("glob" is not working)
I'm using Jython 2.0 pre-alpha on java 1.3.0
_I
-----Original Message-----
From: jyt...@li...
[mailto:jyt...@li...]On Behalf Of Seshu
Nimmala
Sent: Wednesday, January 03, 2001 12:14 PM
To: jyt...@li...
Cc: ses...@sd...
Subject: [Jython-dev] Jython glob/re modules
Hi,
I'm not able to import "glob" module or "re" module for use in jython.
I'm using jython-2.0a2.
Is it a bug or a current limitation?
Thanks,
Seshu
_______________________________________________
Jython-dev mailing list
Jyt...@li...
http://lists.sourceforge.net/mailman/listinfo/jython-dev
|
|
From: Ivan K. <iv...@ko...> - 2001-01-03 20:48:12
|
speaking of unsupported modules.. prior to the release of the final version of jython, it would be nice to have a list of all of the supported modules. Also, it would be great to somehow coordinate the integration/functionality/unit testing of those modules, or at least to see a list of modules that have been or haven't been tested. Thanks, _I -----Original Message----- From: jyt...@li... [mailto:jyt...@li...]On Behalf Of Seshu Nimmala Sent: Wednesday, January 03, 2001 12:14 PM To: jyt...@li... Cc: ses...@sd... Subject: [Jython-dev] Jython glob/re modules Hi, I'm not able to import "glob" module or "re" module for use in jython. I'm using jython-2.0a2. Is it a bug or a current limitation? Thanks, Seshu _______________________________________________ Jython-dev mailing list Jyt...@li... http://lists.sourceforge.net/mailman/listinfo/jython-dev |
|
From: Seshu N. <ses...@sd...> - 2001-01-03 22:56:56
|
Thanks finn. I downloaded the latest jython-2.0b1 and it
imports the glob/re modules as stand-alone execution (at
command line).
However, the glob module still cannot be imported when tried
as below in Java code:
Is there any special command to be used or something like
special setting for PYTHONPATH or someother env
variables to be used to run this Java source:
Any help will be appreciated.
Thanks.
__________________________________________
import org.python.util.PythonInterpreter;
import org.python.core.*;
import java.util.*;
public class
PythonInterpreterTest{
PythonInterpreter interp =
new PythonInterpreter();
public void test() throws PyException {
:
interp.exec("import glob"); //Cannot import glob here
interp.exec("files = glob.glob('*.java')");
}
}
__________________________________________________
[Seshu Nimmala]
>I'm not able to import "glob" module or "re" module for use in jython.
>I'm using jython-2.0a2.
>Is it a bug or a current limitation?
It was a bug in alpha2. The re.py from CPython2.0 wasn't included in the
installer. It is fixed in beta1.
regards,
finn
>
|
|
From: Robert W. B. <rb...@di...> - 2001-01-04 00:26:37
|
Seshu Nimmala wrote:
> Thanks finn. I downloaded the latest jython-2.0b1 and it
> imports the glob/re modules as stand-alone execution (at
> command line).
>
> However, the glob module still cannot be imported when tried
> as below in Java code:
> Is there any special command to be used or something like
> special setting for PYTHONPATH or someother env
> variables to be used to run this Java source:
> Any help will be appreciated.
> Thanks.
> __________________________________________
> import org.python.util.PythonInterpreter;
> import org.python.core.*;
> import java.util.*;
>
> public class
> PythonInterpreterTest{
> PythonInterpreter interp =
> new PythonInterpreter();
> public void test() throws PyException {
> :
> interp.exec("import glob"); //Cannot import glob here
> interp.exec("files = glob.glob('*.java')");
> }
> }
> __________________________________________________
Hello Seshu,
I tried a slightly modified version of your code
and it worked fine (in jython-2.0b1). Here's what I used:
==========================================================
import org.python.util.PythonInterpreter;
import org.python.core.*;
public class
test{
public static void main(String[] args) throws PyException {
PythonInterpreter interp =
new PythonInterpreter();
interp.exec("import glob");
interp.exec("files = glob.glob('*.java')");
interp.exec("print files");
}
}
===========================================================
When I run this I get the output:
['test.java']
I'm curious what happens when you run something like this:
==========================================================
import org.python.util.PythonInterpreter;
import org.python.core.*;
public class
test{
public static void main(String[] args) throws PyException {
PythonInterpreter interp =
new PythonInterpreter();
interp.exec("import sys");
interp.exec("print sys.path");
}
}
===============================================================
For me, I get the following path, which is good because that is where
glob.py is:
['.', '/usr/local/jython-2.0b1/Lib']
This is just a guess, but I suspect that this path will be wrong for
you. Could you have moved jython.jar out of it's installation
directory? You can try running your test with-
"java -Dpython.home=/path/to/jythondir test"
You can guaruntee that this path is correct by initializing a sys.path
list in your java file. This example is from Finn Bock (tnx Finn for
your amazing work)-
Properties props = new Properties();
props.setProperty("python.path", "/home/modules:scripts");
PySystemState.initialize(System.getProperties(), props,
new String[] {""});
The value for python.path must follow the operating system conventions
for the PATH environment var (':' separator for unix, ';' for windows)
regards,
Robert
|
|
From: Seshu N. <Ses...@sd...> - 2001-01-04 01:51:49
|
Robert,
Thank you very much for suggesting more than one way to solve this issue.
As you rightly guessed, I moved the jar file elsewhere and .py files in
installed lib directory are not seen by the Interpreter. Copying the lib files
(such as glob.py) into right location solved the problem!
Your code examples are really good to understand the issue.
However, since the glob module doesn't form part of jython.jar, how could this
be supplied to user/customer (not that I'm intending, but just curious to know!)
Thanks,
Seshu
"Robert W. Bill" wrote:
> Seshu Nimmala wrote:
> > Thanks finn. I downloaded the latest jython-2.0b1 and it
> > imports the glob/re modules as stand-alone execution (at
> > command line).
> >
> > However, the glob module still cannot be imported when tried
> > as below in Java code:
> > Is there any special command to be used or something like
> > special setting for PYTHONPATH or someother env
> > variables to be used to run this Java source:
> > Any help will be appreciated.
> > Thanks.
> > __________________________________________
> > import org.python.util.PythonInterpreter;
> > import org.python.core.*;
> > import java.util.*;
> >
> > public class
> > PythonInterpreterTest{
> > PythonInterpreter interp =
> > new PythonInterpreter();
> > public void test() throws PyException {
> > :
> > interp.exec("import glob"); //Cannot import glob here
> > interp.exec("files = glob.glob('*.java')");
> > }
> > }
> > __________________________________________________
>
> Hello Seshu,
> I tried a slightly modified version of your code
> and it worked fine (in jython-2.0b1). Here's what I used:
> ==========================================================
> import org.python.util.PythonInterpreter;
> import org.python.core.*;
>
> public class
> test{
> public static void main(String[] args) throws PyException {
> PythonInterpreter interp =
> new PythonInterpreter();
> interp.exec("import glob");
> interp.exec("files = glob.glob('*.java')");
> interp.exec("print files");
> }
> }
> ===========================================================
> When I run this I get the output:
> ['test.java']
>
> I'm curious what happens when you run something like this:
> ==========================================================
> import org.python.util.PythonInterpreter;
> import org.python.core.*;
>
> public class
> test{
> public static void main(String[] args) throws PyException {
> PythonInterpreter interp =
> new PythonInterpreter();
> interp.exec("import sys");
> interp.exec("print sys.path");
> }
> }
> ===============================================================
>
> For me, I get the following path, which is good because that is where
> glob.py is:
> ['.', '/usr/local/jython-2.0b1/Lib']
>
> This is just a guess, but I suspect that this path will be wrong for
> you. Could you have moved jython.jar out of it's installation
> directory? You can try running your test with-
> "java -Dpython.home=/path/to/jythondir test"
>
> You can guaruntee that this path is correct by initializing a sys.path
> list in your java file. This example is from Finn Bock (tnx Finn for
> your amazing work)-
>
> Properties props = new Properties();
> props.setProperty("python.path", "/home/modules:scripts");
> PySystemState.initialize(System.getProperties(), props,
> new String[] {""});
>
> The value for python.path must follow the operating system conventions
> for the PATH environment var (':' separator for unix, ';' for windows)
>
> regards,
> Robert
|
|
From: <bc...@wo...> - 2001-01-04 15:54:45
|
[Seshu Nimmala] >However, since the glob module doesn't form part of jython.jar, how could this >be supplied to user/customer (not that I'm intending, but just curious to know!) The usual way is by using some kind of installer (InstallShield, Wyse, LiftOff, ...) and copy the required python modules to the custumer computer. Perhaps you can also use jythonc to freeze the application with the --deep option. All dependent modules will then be frozen together with the application and can be placed in a .jar file. regards, finn |
|
From: <bc...@wo...> - 2001-01-03 20:55:30
|
[Seshu Nimmala] >I'm not able to import "glob" module or "re" module for use in jython. >I'm using jython-2.0a2. >Is it a bug or a current limitation? It was a bug in alpha2. The re.py from CPython2.0 wasn't included in the installer. It is fixed in beta1. regards, finn |