Can't get RDFlib to work on windows
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:开发者_StackOverflow中文版//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'
In the meantime I found a workaround which is to install minGW32 and compile it with that. So for anyone with a similar problem:
- Download minGW32 installer from sourceforge
- When you install the tool and get the screen asking what components to install, select "MinGW base tools", "g++ compiler" and "MingW make".
- After MinGW is installed, add C:\MinGW\bin to your Path environment variable
from http://code.google.com/p/rdflib/issues/detail?id=104#c4
Ok I finally found the answer. You can read it here: http://blog.eddsn.com/2010/05/unable-to-find-vcvarsall-bat/
精彩评论