环境: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. AI解译遥感影像,商汤的“黑科技”了解一下
  2. 独家 | 如何跳出编程这个坑
  3. 图像拐点检测-原理以及代码实现
  4. 2017年第八届蓝桥杯C/C++ A组国赛 —— 第一题:平方十位数
  5. SQL取出第 m 条到第 n 条记录的方法
  6. 使用Apache Camel通过soap添加WS-Security
  7. 计算机组装与维护课程教学内容,《计算机组装与维护》课程教学计划
  8. linux源代码剖析之lib
  9. stm单片机的后缀含义
  10. 计算机丢失bass,dll,bassasio.dll(缺失bassasio.dll文件修复工具)V1.0 正式版
  11. 王垠面阿里P9,面跪后与P10赵海平互怼:人性最大的愚蠢,是互相为难
  12. linux系统下/etc目录的理解
  13. 论strpos 的正确使用方式
  14. win10 蓝牙耳机已连接但是耳机仍没有声音,音频仍是扬声器输出问题的出现条件及解决方案
  15. 浙江大学翁恺C++自学笔记
  16. 设置deepin国内源
  17. 直流输入过压保护电路
  18. 美国ZIPnbsp;Codenbsp;一览表
  19. apicloud 不干胶标签打印模块及开发
  20. matlab滤波实验,卡尔曼滤波实验及matlab实现

热门文章

  1. Trucksim+Prescan+Simulink联合仿真笔记(Carsim同理)
  2. 选用pdf转cad最好的软件转换操作
  3. 论文翻译器+知云+百度API+计算机术语库
  4. SSL certificate problem: unable to get local issuer certificate解决办法
  5. java form的时间格式_java date日期格式
  6. ORA-8102报错的修复方式
  7. 紫外光刻胶 AR-N 4400/电子束光刻胶 AR-N7700/AR-P617 电子束光刻胶
  8. FPGA IN 消费电子
  9. 华为HG8245C光猫设置VOIP
  10. arcgis 空间数据 坐标转换 工具