ModuleNotFoundError: No module named 'rdflib'

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

ModuleNotFoundError: No module named 'rdflib'

s4mamisc
Hello,
I am trying to execute sparql queries. But whenever I try to execute the method

graph = my_world.as_rdflib_graph()

I immediately get an error:

ModuleNotFoundError: no module named 'rdflib'


I installed the latest version of owlready2  from Nov 7, 2019

Below is a screenshot of my code and the exact error message I get. Any ideas how I can fix this error.

Regards Marcel

image:
https://imgur.com/a/PyDzZxC


code:

from owlready2 import *
from time import sleep

my_world = World()
# onto = my_world.get_ontology("C:/Users/Mischo/Desktop/Backup/FTOnto/FTOnto.owl").load()
onto = my_world.get_ontology("http://www.lesfleursdunormal.fr/static/_downloads/pizza_onto.owl").load()

sync_reasoner(my_world, keep_tmp_file=True)

print("reasoning successful")
sleep(1)

print("trying to create a graph")
graph = my_world.as_rdflib_graph()

request = """SELECT ?x ?y ?z WHERE {
  ?x ?y ?z .
}
"""
results = list(graph.query(request))
print(results)
Reply | Threaded
Open this post in threaded view
|

Re: ModuleNotFoundError: No module named 'rdflib'

Jiba
Administrator
Hello,

To use SPARQL, you need to install the "rdflib" Python module.

You can use pip to install it.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: ModuleNotFoundError: No module named 'rdflib'

s4mamisc
Hello Jiba

Thanks a lot

SPARQL Queries work perfectly fine now