Don't understand why this AttributeError: 'Graph' object has no attribute 'merge_one' is occurring
Don't understand why this AttributeError: 'Graph' object has no attribute 'merge_one' is occurring
我正在学习教程,我正在使用最后一个 python2(自制软件)和 PyCharm(配置了项目解释器)- 但我被困在这部分:
from py2neo import Graph, Node
graph = Graph()
nicole = Node("Person", name="Nicole")
graph.create(nicole)
graph.delete(nicole)
nicole = graph.merge_one("Person", "name", "Nicole")
错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Graph' object has no attribute 'merge_one'
我已经检查了 documentation,看来我一切正常。我尝试卸载并安装最新版本的 py2neo 但没有成功。我如何解决这个问题?
预期行为:运行 来自 python2 控制台的命令:如果该人存在,请不要复制它,而是更改其值,如果不存在,请创建它。
通过检查 the source code,我认为您要查找的函数是 Graph.match_one
。还有一个函数 Graph.merge
,但它没有将 Node
作为参数。
我很快就使用了版本 4 而不是版本 2。所以使用 Graph.merge,正如@littlebenlittle 所建议的那样,解决了问题:
jonh = Node("Person", name="Jonh", age = 21)
graph.create(jonh)
ana = Node("Person", name="Ana", age = 44)
graph.create(ana)
michael = Node("Person", name="Ana", age = 33)
graph.merge(michael, "Person", "name") # So the age of Ana will change to 33, as expected.
要使用与我的问题相关的命令,必须安装版本 2,例如。直接来自 py2neo 仓库:
pip install https://github.com/technige/py2neo/archive/release/2.0.7.zip
我正在学习教程,我正在使用最后一个 python2(自制软件)和 PyCharm(配置了项目解释器)- 但我被困在这部分:
from py2neo import Graph, Node
graph = Graph()
nicole = Node("Person", name="Nicole")
graph.create(nicole)
graph.delete(nicole)
nicole = graph.merge_one("Person", "name", "Nicole")
错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Graph' object has no attribute 'merge_one'
我已经检查了 documentation,看来我一切正常。我尝试卸载并安装最新版本的 py2neo 但没有成功。我如何解决这个问题?
预期行为:运行 来自 python2 控制台的命令:如果该人存在,请不要复制它,而是更改其值,如果不存在,请创建它。
通过检查 the source code,我认为您要查找的函数是 Graph.match_one
。还有一个函数 Graph.merge
,但它没有将 Node
作为参数。
我很快就使用了版本 4 而不是版本 2。所以使用 Graph.merge,正如@littlebenlittle 所建议的那样,解决了问题:
jonh = Node("Person", name="Jonh", age = 21)
graph.create(jonh)
ana = Node("Person", name="Ana", age = 44)
graph.create(ana)
michael = Node("Person", name="Ana", age = 33)
graph.merge(michael, "Person", "name") # So the age of Ana will change to 33, as expected.
要使用与我的问题相关的命令,必须安装版本 2,例如。直接来自 py2neo 仓库:
pip install https://github.com/technige/py2neo/archive/release/2.0.7.zip