raise ServiceUnavailable(str(error)) from error neo4j.exceptions.ServiceUnavailable: The Neo4J server does not support
communication with this driver. This driver have support for Bolt
Protocols dict_keys([Version(3, 0), Version(4, 0)])
python访问Neo4j有两种方式:
1,python的py2neo模块
from py2neo import Graph
class Init_Neo4j_driver:
def init(self,uri,user,password):
self.driver = Graph(uri,auth = (user,password))
print('链接数据库成功......')
neo4j_driver = Init_Neo4j_driver(“bolt://127.0.0.1:7687”, “neo4j”, “neo4j”)
driver = neo4j_driver.driver
cql = “MATCH (n) RETURN n.name”
data= driver.run(cql).data()
就可以得到想要的数据了
2,python的neo4j模块
from neo4j import GraphDatabase
class Init_Neo4j_driver:
def __init__(self,uri,user,password):
self.driver = GraphDatabase.driver(uri,auth=(user,password))
def close(self):
self.driver.close()
neo4j_driver = Init_Neo4j_driver(“bolt://127.0.0.1:7687”, “neo4j”, “neo4j”)
driver = neo4j_driver.driver
cql = “MATCH (n) RETURN n.name”
with driver.session() as session:
mark = session.run(cql).data()
其中使用Neo4j模块报以上的错误
看过一些文章说:
neo4j-driver 版本必须是1.7.6
但是还是会出现以上错误:
最后把neo4j-driver的版本换成了1.7.2 链接成功
neo4j 模块版本为4.0.2