Can't get RDFlib to work on windows

Posted by john on Stack Overflow See other posts from Stack Overflow or by john
Published on 2010-05-19T13:54:47Z Indexed on 2010/05/19 19:30 UTC
Read the original article Hit count: 292

Filed under:

I have installed RDFlib 3.0 and everything that is needed, but when I run the following code I get an error. The code below is from: http://code.google.com/p/rdflib/wiki/IntroSparql. I have tried for hours to fix this but with no success. Can please someone help?

import rdflib
rdflib.plugin.register('sparql', rdflib.query.Processor,
                       'rdfextras.sparql.processor', 'Processor')
rdflib.plugin.register('sparql', rdflib.query.Result,
                       'rdfextras.sparql.query', 'SPARQLQueryResult')

from rdflib import ConjunctiveGraph
g = ConjunctiveGraph()
g.parse("http://bigasterisk.com/foaf.rdf")
g.parse("http://www.w3.org/People/Berners-Lee/card.rdf")

from rdflib import Namespace
FOAF = Namespace("http://xmlns.com/foaf/0.1/")
g.parse("http://danbri.livejournal.com/data/foaf")
[g.add((s, FOAF['name'], n)) for s,_,n in g.triples((None, FOAF['member_name'], None))]

for row in g.query(
        """SELECT ?aname ?bname
           WHERE {
              ?a foaf:knows ?b .
              ?a foaf:name ?aname .
              ?b foaf:name ?bname .
           }""",
        initNs=dict(foaf=Namespace("http://xmlns.com/foaf/0.1/"))):
    print "%s knows %s" % row

The error I get is:

Traceback (most recent call last):
  File "...", line 18 in <module>
    initNs=dict(foaf=Namespace("http://xmlns.com/foaf/0.1/"))):
TypeError: query() got an unexpected keyword argument 'initNS'

© Stack Overflow or respective owner

Related posts about rdflib