Message3670
I've tried to use Pyke (the Python Knowledge Engine, s.
http://pyke.sourceforge.net) with Jython and have encountered the
following exception message when trying to compile it by using jython
2.5alpha 3 and even the jython-dev trunk:
>>> import Test
internal compiler error: Name
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "Test.py", line 3, in <module>
import Reasoner
File "Reasoner.py", line 4, in <module>
KnowledgeEngine = pyke.knowledge_engine.engine('.')
File
"D:\Tools\Python\Jython-2.5a3\Lib\site-packages\pyke\knowledge_engine.py"
, line 90, in __init__
from pyke import krb_compiler
File
"D:\Tools\Python\Jython-2.5a3\Lib\site-packages\pyke\krb_compiler\__init_
_.py", line 31, in <module>
from pyke.krb_compiler import compiler_bc
java.lang.NullPointerException
at
org.python.compiler.CodeCompiler.visitName(CodeCompiler.java:1965)
at org.python.antlr.ast.Name.accept(Name.java:50)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.set(CodeCompiler.java:196)
at org.python.compiler.CodeCompiler.set(CodeCompiler.java:187)
at
org.python.compiler.CodeCompiler.visitGeneratorExp(CodeCompiler.java:
2060)
at org.python.antlr.ast.GeneratorExp.accept(GeneratorExp.java:71)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.makeArray(CodeCompiler.java:342)
at
org.python.compiler.CodeCompiler.visitCall(CodeCompiler.java:1503)
at org.python.antlr.ast.Call.accept(Call.java:114)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at
org.python.compiler.CodeCompiler.visitGeneratorExp(CodeCompiler.java:
2063)
at org.python.antlr.ast.GeneratorExp.accept(GeneratorExp.java:71)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at
org.python.compiler.CodeCompiler.invokeNoKeywords(CodeCompiler.java:1
444)
at
org.python.compiler.CodeCompiler.visitCall(CodeCompiler.java:1484)
at org.python.antlr.ast.Call.accept(Call.java:114)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at
org.python.compiler.CodeCompiler.invokeNoKeywords(CodeCompiler.java:1
439)
at
org.python.compiler.CodeCompiler.visitCall(CodeCompiler.java:1484)
at org.python.antlr.ast.Call.accept(Call.java:114)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at
org.python.compiler.CodeCompiler.visitCall(CodeCompiler.java:1512)
at org.python.antlr.ast.Call.accept(Call.java:114)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at
org.python.compiler.CodeCompiler.invokeNoKeywords(CodeCompiler.java:1
450)
at
org.python.compiler.CodeCompiler.visitCall(CodeCompiler.java:1484)
at org.python.antlr.ast.Call.accept(Call.java:114)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.doTest(CodeCompiler.java:889)
at org.python.compiler.CodeCompiler.visitIf(CodeCompiler.java:914)
at org.python.antlr.ast.If.accept(If.java:93)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.suite(CodeCompiler.java:1246)
at org.python.compiler.CodeCompiler.doTest(CodeCompiler.java:894)
at org.python.compiler.CodeCompiler.visitIf(CodeCompiler.java:914)
at org.python.antlr.ast.If.accept(If.java:93)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.suite(CodeCompiler.java:1246)
at org.python.compiler.CodeCompiler.doTest(CodeCompiler.java:894)
at org.python.compiler.CodeCompiler.visitIf(CodeCompiler.java:914)
at org.python.antlr.ast.If.accept(If.java:93)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.suite(CodeCompiler.java:1246)
at org.python.compiler.CodeCompiler.visitFor(CodeCompiler.java:1018)
at org.python.antlr.ast.For.accept(For.java:104)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.suite(CodeCompiler.java:1246)
at
org.python.compiler.CodeCompiler.visitWith(CodeCompiler.java:2126)
at org.python.antlr.ast.With.accept(With.java:82)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.suite(CodeCompiler.java:1246)
at org.python.compiler.CodeCompiler.doTest(CodeCompiler.java:894)
at org.python.compiler.CodeCompiler.visitIf(CodeCompiler.java:914)
at org.python.antlr.ast.If.accept(If.java:93)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.suite(CodeCompiler.java:1246)
at
org.python.compiler.CodeCompiler.visitTryFinally(CodeCompiler.java:11
10)
at org.python.antlr.ast.TryFinally.accept(TryFinally.java:81)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.suite(CodeCompiler.java:1246)
at org.python.compiler.CodeCompiler.doTest(CodeCompiler.java:894)
at org.python.compiler.CodeCompiler.visitIf(CodeCompiler.java:914)
at org.python.antlr.ast.If.accept(If.java:93)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.suite(CodeCompiler.java:1246)
at
org.python.compiler.CodeCompiler.visitSuite(CodeCompiler.java:1240)
at org.python.antlr.ast.Suite.accept(Suite.java:58)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.parse(CodeCompiler.java:269)
at org.python.compiler.Module.PyCode(Module.java:467)
at
org.python.compiler.CodeCompiler.visitFunctionDef(CodeCompiler.java:4
06)
at org.python.antlr.ast.FunctionDef.accept(FunctionDef.java:98)
at org.python.antlr.ast.Module.traverse(Module.java:65)
at org.python.antlr.Visitor.traverse(Visitor.java:12)
at
org.python.compiler.CodeCompiler.visitModule(CodeCompiler.java:310)
at org.python.antlr.ast.Module.accept(Module.java:58)
at org.python.antlr.Visitor.visit(Visitor.java:26)
at org.python.compiler.CodeCompiler.parse(CodeCompiler.java:269)
at org.python.compiler.Module.PyCode(Module.java:467)
at org.python.compiler.Module.compile(Module.java:646)
at org.python.core.imp.compileSource(imp.java:203)
at org.python.core.imp.createFromSource(imp.java:224)
at org.python.core.imp.loadFromSource(imp.java:478)
at org.python.core.imp.find_module(imp.java:379)
at org.python.core.PyModule.impAttr(PyModule.java:109)
at org.python.core.imp.import_next(imp.java:566)
at org.python.core.imp.import_name(imp.java:694)
at org.python.core.imp.importName(imp.java:724)
at org.python.core.ImportFunction.load(__builtin__.java:1268)
at org.python.core.ImportFunction.__call__(__builtin__.java:1264)
at org.python.core.PyObject.__call__(PyObject.java:251)
at org.python.core.__builtin__.__import__(__builtin__.java:1225)
at org.python.core.imp.importFromAs(imp.java:775)
at org.python.core.imp.importFrom(imp.java:761)
at
pyke.krb_compiler$py.f$0(D:\Tools\Python\Jython-2.5a3\Lib\site-packag
es\pyke\krb_compiler\__init__.py)
at
pyke.krb_compiler$py.call_function(D:\Tools\Python\Jython-2.5a3\Lib\s
ite-packages\pyke\krb_compiler\__init__.py)
at org.python.core.PyTableCode.call(PyTableCode.java:187)
at org.python.core.PyCode.call(PyCode.java:14)
at org.python.core.imp.createFromCode(imp.java:258)
at org.python.core.imp.createFromPyClass(imp.java:107)
at org.python.core.imp.loadFromSource(imp.java:471)
at org.python.core.imp.find_module(imp.java:379)
at org.python.core.PyModule.impAttr(PyModule.java:109)
at org.python.core.imp.import_next(imp.java:566)
at org.python.core.imp.import_name(imp.java:694)
at org.python.core.imp.importName(imp.java:724)
at org.python.core.ImportFunction.load(__builtin__.java:1268)
at org.python.core.ImportFunction.__call__(__builtin__.java:1264)
at org.python.core.PyObject.__call__(PyObject.java:251)
at org.python.core.__builtin__.__import__(__builtin__.java:1225)
at org.python.core.imp.importFromAs(imp.java:775)
at org.python.core.imp.importFrom(imp.java:761)
at
pyke.knowledge_engine$py.__init__$7(D:\Tools\Python\Jython-2.5a3\Lib\
site-packages\pyke\knowledge_engine.py)
at
pyke.knowledge_engine$py.call_function(D:\Tools\Python\Jython-2.5a3\L
ib\site-packages\pyke\knowledge_engine.py)
at org.python.core.PyTableCode.call(PyTableCode.java:187)
at org.python.core.PyTableCode.call(PyTableCode.java:415)
at org.python.core.PyTableCode.call(PyTableCode.java:309)
at org.python.core.PyFunction.__call__(PyFunction.java:333)
at
org.python.core.PyMethod.instancemethod___call__(PyMethod.java:130)
at org.python.core.PyMethod.__call__(PyMethod.java:99)
at
org.python.core.PyObjectDerived.dispatch__init__(PyObjectDerived.java
:1090)
at org.python.core.PyType.invoke_new_(PyType.java:287)
at org.python.core.PyType.type___call__(PyType.java:1233)
at org.python.core.PyType.__call__(PyType.java:1224)
at org.python.core.PyObject.__call__(PyObject.java:273)
at Reasoner$py.f$0(Reasoner.py)
at Reasoner$py.call_function(Reasoner.py)
at org.python.core.PyTableCode.call(PyTableCode.java:187)
at org.python.core.PyCode.call(PyCode.java:14)
at org.python.core.imp.createFromCode(imp.java:258)
at org.python.core.imp.createFromPyClass(imp.java:107)
at org.python.core.imp.loadFromSource(imp.java:471)
at org.python.core.imp.find_module(imp.java:379)
at org.python.core.imp.import_next(imp.java:564)
at org.python.core.imp.import_name(imp.java:664)
at org.python.core.imp.importName(imp.java:724)
at org.python.core.ImportFunction.load(__builtin__.java:1268)
at org.python.core.ImportFunction.__call__(__builtin__.java:1264)
at org.python.core.PyObject.__call__(PyObject.java:251)
at org.python.core.__builtin__.__import__(__builtin__.java:1225)
at org.python.core.imp.importOne(imp.java:735)
at Test$py.f$0(Test.py)
at Test$py.call_function(Test.py)
at org.python.core.PyTableCode.call(PyTableCode.java:187)
at org.python.core.PyCode.call(PyCode.java:14)
at org.python.core.imp.createFromCode(imp.java:258)
at org.python.core.imp.createFromPyClass(imp.java:107)
at org.python.core.imp.loadFromSource(imp.java:471)
at org.python.core.imp.find_module(imp.java:379)
at org.python.core.imp.import_next(imp.java:564)
at org.python.core.imp.import_name(imp.java:664)
at org.python.core.imp.importName(imp.java:724)
at org.python.core.ImportFunction.load(__builtin__.java:1268)
at org.python.core.ImportFunction.__call__(__builtin__.java:1264)
at org.python.core.PyObject.__call__(PyObject.java:251)
at org.python.core.__builtin__.__import__(__builtin__.java:1225)
at org.python.core.imp.importOne(imp.java:735)
at org.python.pycode._pyx1.f$0(<stdin>)
at org.python.pycode._pyx1.call_function(<stdin>)
at org.python.core.PyTableCode.call(PyTableCode.java:187)
at org.python.core.PyCode.call(PyCode.java:14)
at org.python.core.Py.runCode(Py.java:1200)
at org.python.core.Py.exec(Py.java:1227)
at
org.python.util.PythonInterpreter.exec(PythonInterpreter.java:134)
at
org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter
.java:90)
at
org.python.util.InteractiveInterpreter.runsource(InteractiveInterpret
er.java:71)
at
org.python.util.InteractiveInterpreter.runsource(InteractiveInterpret
er.java:46)
at
org.python.util.InteractiveConsole.push(InteractiveConsole.java:110)
at
org.python.util.InteractiveConsole.interact(InteractiveConsole.java:9
0)
at org.python.util.jython.run(jython.java:294)
at org.python.util.jython.main(jython.java:114)
java.lang.NullPointerException: java.lang.NullPointerException
>>>
It seems that import of module packages, i.e. the statement "from
pyke.krb_compiler import compiler_bc" in the
pyke/krb_compiler/__init__.py poses some difficulties.
As a test just download pyke, version 0.4 from
http://sourceforge.net/project/showfiles.php?group_id=207724 and use the
following files int the same directory: TestJython.krb, TestIP.py
(Sorry, there is no way to upload several files). And use "import TestIP".
TestJython.krb:
inner_goal
use inner_goal($Tuple, $Member)
when
$Member in $Tuple
python print "inner_goal: member is %s" % $Member
check ($Member in [1,2,3,4])
#special.claim_goal()
outer_goal1
use outer_goal1($TupleT)
when
forall
$Tuple in $TupleT
require
inner_goal($Tuple, $Part)
python print "outer_goal: forall-require: part %s in tuple %s"
%($Part, repr($Tuple))
python print "outer_goal: after forall: tuple of tuple %s" % repr($TupleT)
outer_goal2
use outer_goal2($TupleT)
when
$Tuple in $TupleT
inner_goal($Tuple, $Part)
python print "outer_goal: forall-require: part %s in tuple %s"
%($Part, repr($Tuple))
python print "outer_goal: after forall: tuple of tuple %s" % repr($TupleT)
TestIP.py:
import pyke.knowledge_engine
KnowledgeEngine = pyke.knowledge_engine.engine('.')
def Test():
KnowledgeEngine.activate('TestJython')
print "doing iron python test"
# for (ans,), plan in Reasoner.KnowledgeEngine.prove_n('Deployment',
'deploy_by_heuristics', ('try1'), 0):
for ans in Reasoner.KnowledgeEngine.prove_n('TestJython',
'outer_goal1', (((1,2), (3,4)),), 0):
print "outer_goal1: %s" % repr(ans)
print ""
for ans in Reasoner.KnowledgeEngine.prove_n('TestJython',
'outer_goal2', (((1,2), (3,4)),), 0):
print "outer_goal2: %s" % repr(ans)
Thanks
Egon |
|
Date |
User |
Action |
Args |
2008-10-13 09:01:32 | egonw_ | set | recipients:
+ egonw_ |
2008-10-13 09:01:32 | egonw_ | set | messageid: <1223888492.19.0.0445607775622.issue1151@psf.upfronthosting.co.za> |
2008-10-13 09:01:32 | egonw_ | link | issue1151 messages |
2008-10-13 09:01:30 | egonw_ | create | |
|