gpt4 book ai didi

rdflib - 无法让 RDFlib 在 Windows 上工作

转载 作者:行者123 更新时间:2023-12-04 06:52:52 24 4
gpt4 key购买 nike

我已经安装了 RDFlib 3.0 和所有需要的东西,但是当我运行以下代码时出现错误。以下代码来自:http://code.google.com/p/rdflib/wiki/IntroSparql .我已经尝试了几个小时来解决这个问题,但没有成功。可以请人帮忙吗?

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

我得到的错误是:
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:

  1. Download minGW32 installer from sourceforge
  2. When you install the tool and get the screen asking what components to install, select "MinGW base tools", "g++ compiler" and "MingW make".
  3. After MinGW is installed, add C:\MinGW\bin to your Path environment variable


来自 http://code.google.com/p/rdflib/issues/detail?id=104#c4

关于rdflib - 无法让 RDFlib 在 Windows 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2866107/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com