当前位置:   article > 正文

Neo4j企业版报错:py2neo.errors.ProtocolError: Cannot decode response content as JSON

py2neo.errors.protocolerror: cannot decode response content as json

py2neo.errors.ProtocolError: Cannot decode response content as JSON

环境为neo4j-enterprise-5.1.0、py2neo、Neo4j Desktop-1.5.2

Traceback (most recent call last):
  File "D:\software\Python\Python37\lib\site-packages\py2neo\client\http.py", line 443, in from_json
    content = json_loads(data, object_hook=JSONHydrant.json_to_packstream)
  File "D:\software\Python\Python37\lib\json\__init__.py", line 361, in loads
    return cls(**kw).decode(s)
  File "D:\software\Python\Python37\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\software\Python\Python37\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:/work/Python/Neo4j2Web/add_atrr/english_name.py", line 17, in <module>
    g.run("MATCH (m:AgriculturePest { name: '" + i + "'}) SET m += {english_name: '" + j + "'}")
  File "D:\software\Python\Python37\lib\site-packages\py2neo\database.py", line 405, in run
    return self.auto().run(cypher, parameters, **kwparameters)
  File "D:\software\Python\Python37\lib\site-packages\py2neo\database.py", line 992, in run
    readonly=self.readonly)
  File "D:\software\Python\Python37\lib\site-packages\py2neo\client\__init__.py", line 1340, in auto_run
    return cx.auto_run(cypher, parameters, graph_name=graph_name, readonly=readonly)
  File "D:\software\Python\Python37\lib\site-packages\py2neo\client\http.py", line 177, in auto_run
    rs = HTTPResponse.from_json(r.status, r.data.decode("utf-8"))
  File "D:\software\Python\Python37\lib\site-packages\py2neo\client\http.py", line 445, in from_json
    raise_from(ProtocolError("Cannot decode response content as JSON"), error)
  File "<string>", line 3, in raise_from
py2neo.errors.ProtocolError: Cannot decode response content as JSON

进程已结束,退出代码为 1

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

根据堆栈追踪,我们发现self.graph.name为空,而self.graph为Graph("http://localhost:7474/ ")

所以我们自己修改源码
打开python的包的安装位置:
X:*****\Python\Python37\Lib\site-packages\py2neo\database.py

原来的代码: (990行左右)

result = self._connector.auto_run(cypher, parameters,
									graph_name=self.graph.name,
									readonly=self.readonly)
  • 1
  • 2
  • 3

更改后的代码:

result = self._connector.auto_run(cypher, parameters,
                                   graph_name="neo4j",
                                   readonly=self.readonly)
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/392140
推荐阅读
相关标签
  

闽ICP备14008679号