环境:neo4j-5.1.0、py2neo-2021.2.3、Neo4j Desktop-1.5.2、python3.9.13

1、创建neo4j链接,对数据库进行增删改的时候报错。

报错代码:

JSONDecodeError                           Traceback (most recent call last)
D:\anaconda3\lib\site-packages\py2neo\client\http.py in from_json(cls, status, data)442         try:
--> 443             content = json_loads(data, object_hook=JSONHydrant.json_to_packstream)444         except ValueError as error:D:\anaconda3\lib\json\__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)358         kw['parse_constant'] = parse_constant
--> 359     return cls(**kw).decode(s)D:\anaconda3\lib\json\decoder.py in decode(self, s, _w)336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())338         end = _w(s, end).end()D:\anaconda3\lib\json\decoder.py in raw_decode(self, s, idx)354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None356         return obj, endJSONDecodeError: Expecting value: line 1 column 1 (char 0)The above exception was the direct cause of the following exception:ProtocolError                             Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_8660\3422543364.py in <module>9         relation = Relationship(start_node,'hasConcept',end_node)10         print(relation)
---> 11         g.merge(start_node,'article_id','article_id')12         g.merge(end_node,'keyword','keyword')13         g.merge(relation,'hasConcept','keyword')D:\anaconda3\lib\site-packages\py2neo\database.py in merge(self, subgraph, label, *property_keys)676         :param property_keys: property keys on which to match any existing nodes677         """
--> 678         self.update(lambda tx: tx.merge(subgraph, label, *property_keys))679 680     @propertyD:\anaconda3\lib\site-packages\py2neo\database.py in update(self, cypher, parameters, timeout)443         if callable(cypher):444             if parameters is None:
--> 445                 self._update(cypher, timeout=timeout)446             elif (isinstance(parameters, tuple) and len(parameters) == 2 and447                     isinstance(parameters[0], Sequence) and isinstance(parameters[1], Mapping)):D:\anaconda3\lib\site-packages\py2neo\database.py in _update(self, f, timeout)465             tx = None466             try:
--> 467                 tx = self.begin(468                                 # after=after, metadata=metadata, timeout=timeout469                                 )D:\anaconda3\lib\site-packages\py2neo\database.py in begin(self, readonly)349         removed. Use the 'auto' method instead.*350         """
--> 351         return Transaction(self, autocommit=False, readonly=readonly,352                            # after, metadata, timeout353                            )D:\anaconda3\lib\site-packages\py2neo\database.py in __init__(self, graph, autocommit, readonly)913             self._ref = None914         else:
--> 915             self._ref = self._connector.begin(self.graph.name, readonly=readonly,916                                               # after, metadata, timeout917                                               )D:\anaconda3\lib\site-packages\py2neo\client\__init__.py in begin(self, graph_name, readonly)1357         cx = self._acquire(graph_name)1358         try:
-> 1359             return cx.begin(graph_name, readonly=readonly,1360                             # after=after, metadata=metadata, timeout=timeout1361                             )D:\anaconda3\lib\site-packages\py2neo\client\http.py in begin(self, graph_name, readonly)197             #     raise TypeError("Transaction timeouts are not supported over HTTP")198             r = self._post(HTTPTransactionRef.begin_uri(graph_name))
--> 199             rs = HTTPResponse.from_json(r.status, r.data.decode("utf-8"))200             location_path = urlsplit(r.headers["Location"]).path201             tx = HTTPTransactionRef(graph_name, location_path.rpartition("/")[-1])D:\anaconda3\lib\site-packages\py2neo\client\http.py in from_json(cls, status, data)443             content = json_loads(data, object_hook=JSONHydrant.json_to_packstream)444         except ValueError as error:
--> 445             raise_from(ProtocolError("Cannot decode response content as JSON"), error)446         else:447             return cls(status, content)D:\anaconda3\lib\site-packages\six.py in raise_from(value, from_value)ProtocolError: Cannot decode response content as JSON

奇怪的是,同样的代码、数据,用在python3.8.3的环境中没有报错,所以首先查看两个版本python的区别,发现json的__init__中有一些小区别,关于json解析的,手动给3.9.13的init进行修改,仍然报错,思考是否是别的问题。

2、寻找其他解决方案

参考了一个解决方案:https://blog.csdn.net/weixin_44155966/article/details/127704336

但是实际上没有解决问题,依然报错。

3、受到方案启发,认为是graph_name为空时的问题

看了上方的解决方案之后,感觉这个报错逻辑有些奇怪,实际上不是json的问题,还是连接neo4j时,指定的graph不够明确,所以在连接时指定name如下:

此时,再次执行控制neo4j的指令代码,就不再报错了。

Neo4j报错:py2neo.errors.ProtocolError: Cannot decode response content as JSON 解决方案相关推荐

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

    py2neo.errors.ProtocolError: Cannot decode response content as JSON 环境为neo4j-enterprise-5.1.0.py2neo ...

  2. conda install 换源_科学网—Anaconda 报错Multiple Errors Encountered和添加国内镜像以及换源和恢复默认源 - 张伟的博文...

    (一)情景一 在安装完成 Anaconda 后,创建虚拟环境接连遇到报错 Multiple Errors Encountered  和 Anaconda An HTTP error occurred ...

  3. read_csv()报错: ‘utf-8‘ codec can‘t decode byte 0xca in position 0: invalid continuation byte

    1.设置 pycharm  UTF-8 编码 Pycharm 设置步骤: 进入 file > Settings,在输入框搜索 encoding. 找到 Editor > File enco ...

  4. Neo4j连接 (Connect to Neo4j) 报错

    问题: Connect to Neo4j报错: ServiceUnavailable: WebSocket connection failure. Due to security constraint ...

  5. Windows下运行rabbitmqctl 相关命令(如rabbitmqctl stop)报错:Error: unable to perform an operation on node解决方案

    Windows下运行rabbitmqctl 相关命令(如rabbitmqctl stop)报错:Error: unable to perform an operation on node解决方案 参考 ...

  6. python3运行报错:TypeError: Object of type ‘type‘ is not JSON serializable解决方法(详细)

    python3运行报错:TypeError: Object of type 'type' is not JSON serializable解决方法(详细) 参考文章: (1)python3运行报错:T ...

  7. 【Flink】Flink 写入 kafka 报错 The server disconnected before a response was received

    文章目录 1.场景再现 1.1.概述 1.场景再现 1.1.概述 Flink 写入 kafka 报错 The server disconnected before a response was rec ...

  8. 安装Python3.5后,pip报错Fatal error in launcher: Unable to create process using ‘“‘解决方案

    安装Python3.5后,pip报错Fatal error in launcher: Unable to create process using '"'解决方案 参考文章: (1)安装Py ...

  9. 关于centos启动报错:Failed to start Crash recovery kernel arming的解决方案

    关于centos启动报错:Failed to start Crash recovery kernel arming的解决方案 参考文章: (1)关于centos启动报错:Failed to start ...

最新文章

  1. java中JVM的原理【转】
  2. 7——ThinkPhp中的响应和重定向:
  3. R语言计算dataframe数据列中各分类的计数(类似pandas value_counts函数功能)
  4. 科学家利用BCI技术来缓解幻肢疼痛
  5. mod php是什么意思,mod函数是什么意思
  6. Android画布的保存,Android canvas用法介绍之save()和restore()
  7. Java-进阶:多线程2
  8. python excel 单元格格式_python设置单元格数值格式
  9. Java环境安装手册
  10. Linux下安装Nginx完整教程及常见错误解决方案
  11. php高效获取数据分页
  12. Ubuntu18.04 安装OpenCV
  13. No package ‘libpeas-1.0‘ found/No package ‘libpeas-gtk-1.0‘
  14. 基于matlab和Simulink的不同阶QAM调制解调系统误码率对比仿真
  15. 计算机加入域后的用户名和密码,Windows自动改计算机名和加入域工具
  16. 祝贺父亲节快乐的python代码_2019祝爸爸父亲节快乐的最新父亲节祝福说说句子大全...
  17. 2022下半年软考考试时间安排已确定!
  18. inno setup 修改将程序安装路径写入注册表
  19. AIX 存储管理 LV PV VG PP
  20. 这样的成品app直播源码到手一定会后悔

热门文章

  1. 我的世界虚拟服务器联机,我的世界模拟城市联机教程-的世界怎么联机
  2. android三种动画的区别,TranslateAnimation详解
  3. win10退出卡巴斯基导致系统蓝屏故障解决办法
  4. 读《道德经》:混职场的你别不服,牛人与普通人,就差这5点!
  5. 【运维面试秘籍】2022最值得收藏的运维面试文章汇总
  6. OpenGLES的shader介绍
  7. 三行代码,轻松实现 Scrapy 对接新兴爬虫神器 Playwright!
  8. Java最后一课*启点
  9. 机器人操作系统ROS理论与实践
  10. java-生成印章swing