Error using sync_reasoner()

classic Classic list List threaded Threaded
7 messages Options
rdk
Reply | Threaded
Open this post in threaded view
|

Error using sync_reasoner()

rdk
Hi,

I have just started using Owlready2 (thank you for this, Jiba!) and crashed into a problem when trying to use the HermiT reasoner on a simple ontology.
Can you explain to me what is happening and help me overcome this error, please? (description below)

Thanks,
Rui

- - - ERROR DESCRIPTION - - -

* Owlready2 * Running HermiT...
    java -Xmx2000M -cp C:\Python35\lib\site-packages\owlready2\hermit;C:\Python35\lib\site-packages\owlready2\hermit\HermiT.jar org.semanticweb.HermiT.cli.CommandLine -c -O -D -I file:///C:/Users/R/AppData/Local/Temp/tmpeb47lx3l
Traceback (most recent call last):
  File "C:\Users\R\path to python script.py", line 12, in <module>
    with onto: sync_reasoner()
  File "C:\Python35\lib\site-packages\owlready2\reasoning.py", line 85, in sync_reasoner
    output = subprocess.check_output(command)
  File "C:\Python35\lib\subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "C:\Python35\lib\subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['java', '-Xmx2000M', '-cp', 'C:\\Python35\\lib\\site-packages\\owlready2\\hermit;C:\\Python35\\lib\\site-packages\\owlready2\\hermit\\HermiT.jar', 'org.semanticweb.HermiT.cli.CommandLine', '-c', '-O', '-D', '-I', 'file:///C:/Users/R/AppData/Local/Temp/tmpeb47lx3l']' returned non-zero exit status 1
[Finished in 0.3s with exit code 1]
[shell_cmd: python -u "C:\Users\R\path to python script.py"]
[dir: C:\Users\R\path to python scripts folder]
[path: C:\Python35\Scripts\;C:\Python35\;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\Calibre2\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files (x86)\OpenVPN\bin;C:\Users\R\AppData\Roaming\npm]
Reply | Threaded
Open this post in threaded view
|

Re: Error using sync_reasoner()

Jiba
Administrator
Hi,

Could you send me the ontology please ? (or a simplified version that still crashes)

Kind regards,
Jean-Baptiste Lamy
rdk
Reply | Threaded
Open this post in threaded view
|

Re: Error using sync_reasoner()

rdk
Thank you for the quick reply!

I have already sent you the document via e-mail.
Best regards,

Rui
Reply | Threaded
Open this post in threaded view
|

Re: Error using sync_reasoner()

Jiba
Administrator
I've tested with the file you sent me; the reasoner works well.

jiba dans src :  python ./test2.py
* Owlready2 * Running HermiT...
    java -Xmx2000M -cp /home/jiba/src/owlready2/hermit:/home/jiba/src/owlready2/hermit/HermiT.jar org.semanticweb.HermiT.cli.CommandLine -c -O -D -I file:////tmp/tmpmdzgooxn
* Owlready2 * HermiT took 1.0704829692840576 seconds
* Owlready * Reparenting bottle_test_rdk.Base: {owl.Thing} => {bottle_test_rdk.Part}
* Owlready * Reparenting bottle_test_rdk.Top: {owl.Thing} => {bottle_test_rdk.Part}
* Owlready * Reparenting bottle_test_rdk.TopSection: {owl.Thing} => {bottle_test_rdk.Section}
* Owlready * Reparenting bottle_test_rdk.BottomSection: {owl.Thing} => {bottle_test_rdk.Section}


So I think you have a problem on your Java installation or configuration. Under windows, you may need to specify the path to Java in the owlready2.JAVA_EXE global variable, for example:

import owlready2
owlready2.JAVA_EXE = "C:\\path\\to\\java.exe"
rdk
Reply | Threaded
Open this post in threaded view
|

Re: Error using sync_reasoner()

rdk
Thanks for the reply, Jiba.

I have reinstalled Java and tried your suggestion, but the problem persists:

Issue #01 - if I do "import owlready2" instead of "from owlready import *", the code will break right at the start returning: « NameError: name 'onto_path' is not defined »

Issue #02 - if I try to specify the path to Java in the owlready2.JAVA_EXE global variable, as you suggested, the code will break returning: « NameError: name 'owlready2' is not defined »

Issue #03 - I added the correct address of java.exe to system path, but the problem with sync_reasoner() persists with the same error...

Any more ideas?

Cheers,
Rui
Reply | Threaded
Open this post in threaded view
|

Re: Error using sync_reasoner()

Jiba
Administrator
For issue #1 and #2, you need to use both kinds of import:

import owlready2
from owlready2 import *

owlready2.JAVA_EXE = "\\path\\to\\java.exe"

...


For issue 3, I'm not sure that adding java to the system path is enought, because under windows java is called "java.exe" instead of "java".


Jean-Baptiste Lamy

> Thanks for the reply, Jiba.
>
> I have reinstalled Java and tried your suggestion, but the problem persists:
>
> *Issue #01* - if I do "/import owlready2/" instead of "/from owlready import
> */", the code will break right at the start returning: « /NameError: name
> 'onto_path' is not defined/ »
>
> *Issue #02* - if I try to specify the path to Java in the owlready2.JAVA_EXE
> global variable, as you suggested, the code will break returning: «
> /NameError: name 'owlready2' is not defined/ »
>
> *Issue #03* - I added the correct address of java.exe to system path, but
> the problem with /sync_reasoner()/ persists with the same error...
>
> Any more ideas?
>
> Cheers,
> Rui
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://owlready.8326.n8.nabble.com/Error-using-sync-reasoner-tp19p23.html
> To start a new topic under Owlready, email [hidden email]
> To unsubscribe from Owlready, visit
rdk
Reply | Threaded
Open this post in threaded view
|

Re: Error using sync_reasoner()

rdk
That did it!
Using both types of import and setting the path to owlready2.JAVA_EXE solved the problem and HermiT is now running.

Thank you once again for your help, Jean-Baptiste.
Looking forward for future developments of Owlready!

Best regards,
Rui