我试图用py2neo 2.0(和Neo4j 2.1.6)执行cypher查询,但它失败并出现以下错误:
文件" C:\ Envs \ project \ lib \ site-packages \ py2neo \ core.py",第678行,cypher
self .__ cypher = CypherResource(元数据[" cypher"],metadata.get(" transaction")) KeyError:" u' cypher'
调试时,我发现元数据属性没有cypher
条目,但我想知道如何解决它。
答案 0 :(得分:8)
使用无效的URI初始化py2neo.Graph
时,可以重现此错误:
>>> from py2neo import Graph
>>> graph = Graph('http://localhost:7474')
>>> test = graph.cypher.execute('MATCH n RETURN n LIMIT 5')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/nicole/Envs/squid/lib/python2.7/site-packages/py2neo/core.py", line 678, in cypher
self.__cypher = CypherResource(metadata["cypher"], metadata.get("transaction"))
KeyError: u'cypher'
也许Nigel可以证实,但根据我对py2neo 2.0的经验,您需要使用/db/data/
端点初始化:
>>> from py2neo import Graph
>>> graph = Graph('http://localhost:7474/db/data/')
>>> test = graph.cypher.execute('MATCH n RETURN n LIMIT 5')