py2neo cypher错误:KeyError:“u'cypher”

时间:2021-05-29 18:04:13

I'm trying to execute a cypher query with py2neo 2.0 (and Neo4j 2.1.6), but it fails with the following error:

我正在尝试使用py2neo 2.0(和Neo4j 2.1.6)执行cypher查询,但它失败了:

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

文件“C:\ env \ \ lib \网站\ py2neo \核心项目。在cypher中,第678行。

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

自我。__cypher = CypherResource(元数据["cypher"], metadata.get("transaction")) KeyError: "u'cypher "

While debugging, I found that the metadata property doesn't have a cypher entry, but I'm wondering how I can solve it.

在调试过程中,我发现元数据属性没有密码条目,但我想知道如何解决它。

py2neo cypher错误:KeyError:“u'cypher”

1 个解决方案

#1


7  

This error can be reproduced when initializing py2neo.Graph with an invalid URI:

这个错误可以在初始化py2neo时复制。图中有一个无效的URI:

>>> 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'

Perhaps Nigel can confirm, but in my experience with py2neo 2.0 you need to initialize with the /db/data/ endpoint:

也许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')

#1


7  

This error can be reproduced when initializing py2neo.Graph with an invalid URI:

这个错误可以在初始化py2neo时复制。图中有一个无效的URI:

>>> 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'

Perhaps Nigel can confirm, but in my experience with py2neo 2.0 you need to initialize with the /db/data/ endpoint:

也许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')