Issue1383
Created on 2009-06-19.15:45:03 by tzellman, last changed 2010-01-26.15:46:04 by tzellman.
| Messages | |||
|---|---|---|---|
| msg4824 (view) | Author: (tzellman) | Date: 2009-06-19.15:45:02 | |
I am using the Jython 2.5 release posted on SourceForge. I am embedding the interpreter inside my Java code. Code that worked perfectly under Jython 2.2 is now failing with an ImportError. Jython is failing to find Java-based modules after I import * from a parent package. For example: from my.java.package import * from my.java.package.checks import * from my.java.package.actions import * Jython fails with this error message: "ImportError: No module named checks" If I instead strip out the * imports and import objects directly from the modules, everything works normally. A little more insight into what I am doing: I create the interpreter, then pass it a string of Python code that essentially loads a directory/module where Jython plug-in scripts are located. Those scripts then import java modules available within the current Java process. |
|||
| msg5454 (view) | Author: Frank Wierzbicki (fwierzbicki) | Date: 2010-01-25.16:21:32 | |
Hi tzellman: I know you submitted this bug a long time ago, but if you are still around, if you could upload test (as small as possible would help) that shows off this bug I can take a look at it. |
|||
| msg5455 (view) | Author: (tzellman) | Date: 2010-01-26.15:46:03 | |
Thanks for responding Frank. I actually just tried 3 different methods of calling/importing python from within Java. You can view what I tested here: http://gist.github.com/286908 For my simple test case, using Jython 2.5.1 worked as expected. :) I also tried Jython 2.5.0, which, aside from not having the interpreter.compile() method, did NOT work. So, it looks like the problem I was having in Jython 2.5.0 were fixed since then. Jython 2.5.0 gives this error stacktrace: Execing: test.py 0.0715102502628 Traceback (most recent call last): File "test.py", line 9, in <module> run() File "test.py", line 6, in run print Utils2.randomString(10) LookupError: no codec search functions registered: can't find encoding at org.python.core.PyException.fillInStackTrace(PyException.java:70) at java.lang.Throwable.<init>(Throwable.java:181) at java.lang.Exception.<init>(Exception.java:29) at java.lang.RuntimeException.<init>(RuntimeException.java:32) at org.python.core.PyException.<init>(PyException.java:46) at org.python.core.PyException.<init>(PyException.java:43) at org.python.core.PyException.<init>(PyException.java:61) at org.python.core.codecs.lookup(codecs.java:80) at org.python.core.codecs.getEncoder(codecs.java:209) at org.python.core.codecs.encode(codecs.java:187) at org.python.core.PyString.str_encode(PyString.java:2429) at org.python.core.PyString.encode(PyString.java:2424) at org.python.core.StdoutWrapper.print(StdoutWrapper.java:111) at org.python.core.StdoutWrapper.println(StdoutWrapper.java:203) at org.python.core.Py.println(Py.java:1329) at org.python.pycode._pyx0.run$1(test.py:6) at org.python.pycode._pyx0.call_function(test.py) at org.python.core.PyTableCode.call(PyTableCode.java:165) at org.python.core.PyBaseCode.call(PyBaseCode.java:117) at org.python.core.PyFunction.__call__(PyFunction.java:307) at org.python.pycode._pyx0.f$0(test.py:9) at org.python.pycode._pyx0.call_function(test.py) at org.python.core.PyTableCode.call(PyTableCode.java:165) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.Py.runCode(Py.java:1197) at org.python.core.__builtin__.execfile_flags(__builtin__.java:538) at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156) at gist.JythonTest.runFile(JythonTest.java:25) at gist.JythonTest.main(JythonTest.java:84 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2010-01-26 15:46:04 | tzellman | set | messages: + msg5455 |
| 2010-01-25 16:21:33 | fwierzbicki | set | nosy:
+ fwierzbicki messages: + msg5454 |
| 2009-06-19 15:45:03 | tzellman | create | |