py2neo cypher error: KeyError: "u'cypher'

py2neo cypher error: KeyError: "u'cypher'

我正在尝试使用 py2neo 2.0(和 Neo4j 2.1.6)执行密码查询,但失败并出现以下错误:

File "C:\Envs\project\lib\site-packages\py2neo\core.py", line 678, in cypher

self.__cypher = CypherResource(metadata["cypher"], metadata.get("transaction")) KeyError: "u'cypher'

在调试时,我发现元数据 属性 没有 cypher 条目,但我想知道如何解决它。

使用无效 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')