[英]Error connecting py2neo
I'm trying to connect my neo4J DB with Python using py2neo. 我正在尝试使用py2neo将neo4J DB与Python连接。
I'm following the example extracted from py2neo 2 API but there's no way to get it work. 我正在遵循从py2neo 2 API中提取的示例,但是无法使其正常工作。
My code: 我的代码:
from py2neo import Graph
graph = Graph("http://neo4j:1234@localhost:7474/C:/Users/htilmatine/Documents/Neo4j/default.graphdb")
The error: 错误:
Traceback (most recent call last):
File "D:\TFG\python\ejm.py", line 1, in <module>
from py2neo import Graph
File "C:\Python27\lib\site-packages\py2neo-2.0a0-py2.7.egg\py2neo\__init__.py", line 27, in <module>
from py2neo.batch import *
File "C:\Python27\lib\site-packages\py2neo-2.0a0-py2.7.egg\py2neo\batch\__init__.py", line 19, in <module>
from py2neo.batch.core import *
File "C:\Python27\lib\site-packages\py2neo-2.0a0-py2.7.egg\py2neo\batch\core.py", line 24, in <module>
from py2neo.core import NodePointer, Service
File "C:\Python27\lib\site-packages\py2neo-2.0a0-py2.7.egg\py2neo\core.py", line 50, in <module>
from py2neo.error.client import BindError, JoinError
ImportError: No module named error.client
The connection docs are here . 连接文档在这里 。
If you're just using a default install and default graph data directory, you should be able to connect with: 如果您仅使用默认的安装目录和默认的图形数据目录,则应该能够连接:
graph = Graph("http://neo4j:1234@localhost:7474/db/data")
or 要么
from py2neo import ServiceRoot
graph = ServiceRoot("http://neo4j:1234@localhost:7474").graph
If you're not using the default data directory then 如果您未使用默认数据目录,则
/neo4j/data
/neo4j/data
的子目录 you need to provide a relative path to it from the neo4j directory in your uri like: 您需要从uri中的neo4j目录提供相对路径,例如:
graph = Graph("http://neo4j:1234@localhost:7474/db/data/my_graph_dir")
EDIT: fixed the first Graph url, and added how to connect with ServiceRoot
编辑:修复了第一个图URL,并添加了如何与
ServiceRoot
连接
I'm concerned about seeing py2neo-2.0a0
in your path name. 我担心在您的路径名中看到
py2neo-2.0a0
。 I'd strongly recommend using a more up-to-date version of py2neo, specifically not an alpha release. 我强烈建议您使用py2neo的最新版本,尤其不要使用Alpha版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.