Neo4j 介绍(三):使用 python 访问 neo4j

这里主要介绍使用 python 访问 neo4j 的方法。

python driver 的地址: https://github.com/neo4j/neo4j-python-driver

需要安装 python 3 版本,然后安装 pip3, 通过 pip3 安装驱动可以把驱动安装到 python 3 对应的库。

安装驱动:

pip install git+https://github.com/neo4j/neo4j-python-driver.git#egg=neo4j

有可能会在运行时报错,

File “/usr/local/lib/python3.4/dist-packages/neobolt/direct.py”, line 123, in supports  return self.version_info() >= (3, 2) TypeError: unorderable types: str() >= int()

定位到报错的文件,发现报错的是 direct.py 文件的supports() 函数。报错的原因的类型不匹配,通过调试发现, self.version_info() 返回的是字符串数组 ('dev',) , 运行 self.version_info() >= (3, 2) 显然就会报错。没有找到有效的解决办法。supports() 函数主要是进行版本检查的,不是核心业务代码,所以目前的解决办法是,直接在 supports() 函数的第一行添加 return True , 默认版本检查通过。然后运行,发现没有报错。

猜你喜欢

转载自blog.csdn.net/c710473510/article/details/89437264