Syntax error

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

Syntax error

George
Hi,

I'm trying to run owlready2 in python 3.5. The pip installation went well, but when I try the command 'from owlready2 import *' I get the following error message:

Traceback (most recent call last):
  File "C:/Users/.../Main.py", line 1, in <module>
    from owlready2 import *
  File "C:\Users\...\lib\site-packages\owlready2\__init__.py", line 111, in <module>
    default_world = IRIS = World()
  File "C:\Users\...\lib\site-packages\owlready2\namespace.py", line 317, in __init__
    self.set_backend(backend, filename, dbname, **kargs)
  File "C:\Users\...\lib\site-packages\owlready2\namespace.py", line 325, in set_backend
    self.graph = Graph(filename, world = self, **kargs)
  File "C:\Users\...\lib\site-packages\owlready2\triplelite.py", line 136, in __init__
    self.execute("""CREATE VIEW quads (c,s,p,o,d) AS SELECT c,s,p,o,NULL FROM objs UNION ALL SELECT c,s,p,o,d FROM datas""")
sqlite3.OperationalError: near "(": syntax error

Would anyone know what's wrong? Thanks in advance! :)
Reply | Threaded
Open this post in threaded view
|

Re: Syntax error

Jiba
Administrator
Hi,

I think the problem is related to the version of SQLite you are using (or possibly the version of Python, since SQLite is embedded in Python standard distribution). The "CREATE VIEW table (columns)" syntax is rather recent (2015) and Python 3.5 is not the latest version.

In the development version on Mercurial, I replaced it by another equivalent syntax that should be better supported by older version of SQLite. Alternatively, you can also replace line 136 in triplelite.py by the following one:

        self.execute("""CREATE VIEW quads AS SELECT c,s,p,o,NULL AS d FROM objs UNION ALL SELECT c,s,p,o,d FROM datas""")

Could you try and tell me if it works now?

Best regards,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Syntax error

George
Hi Jiba,

Thanks for the very quick reply. :) I updated to the most recent version of Python and SQLite and and replaced the line as suggested, and now the syntax error seems to have disappeared. There has however occured a new error when I try to use the get_ontology function as described in the documentation, which I'm not sure how to interpret:

Traceback (most recent call last):
  File "C:\Users\...\lib\site-packages\owlready2\rdfxml_2_ntriples.py", line 313, in parse
    parser.ParseFile(f)
  File "c:\_work\4\s\modules\pyexpat.c", line 466, in EndElement
  File "C:\Users\...\lib\site-packages\owlready2\rdfxml_2_ntriples.py", line 277, in endElement
    elif d in FLOAT_DATATYPES: o = float(o)
ValueError: could not convert string to float: 'undefined'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:/Users/.../Main.py", line 3, in <module>
    ontology = get_ontology("file://ontology_complete.owl").load()
  File "C:\Users\...\lib\site-packages\owlready2\namespace.py", line 624, in load
    try:     new_base_iri = self.graph.parse(fileobj, default_base = self.base_iri, **args)
  File "C:\Users\...\lib\site-packages\owlready2\driver.py", line 193, in parse
    raise e
  File "C:\Users\...\lib\site-packages\owlready2\driver.py", line 189, in parse
    owlready2.rdfxml_2_ntriples.parse(f, on_prepare_obj, on_prepare_data, new_blank, default_base)
  File "C:\Users\...\lib\site-packages\owlready2\rdfxml_2_ntriples.py", line 315, in parse
    raise OwlReadyOntologyParsingError("RDF/XML parsing error in file %s, line %s, column %s." % (getattr(f, "name", "???"), parser.CurrentLineNumber, parser.CurrentColumnNumber)) from e
owlready2.base.OwlReadyOntologyParsingError: RDF/XML parsing error in file ontology_complete.owl, line 596, column 88.


Would you have any idea what might cause this? Sorry for keeping bothering you but I'm not sure what to make of this..
Reply | Threaded
Open this post in threaded view
|

Re: Syntax error

Jiba
Administrator
Hi,

I suspect that, in the ontology OWL file, there is "undefined" value instead of a floating point point ?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Syntax error

George
Hi Jiba,

You're right; apologies, my mistake. Everything's working now. :) Thanks a lot for the help!

All the best!