Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

py2neo cypher error: KeyError: "u'cypher'

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

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'

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

enter image description here

like image 939
Daniel Silva Avatar asked May 09 '26 22:05

Daniel Silva


1 Answers

This error can be reproduced when initializing py2neo.Graph with an invalid 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:

>>> from py2neo import Graph
>>> graph = Graph('http://localhost:7474/db/data/')
>>> test = graph.cypher.execute('MATCH n RETURN n LIMIT 5')
like image 187
Nicole White Avatar answered May 11 '26 15:05

Nicole White



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!